diff --git a/token_bot/tracker.py b/token_bot/tracker.py index 5eb3857..41f8dca 100644 --- a/token_bot/tracker.py +++ b/token_bot/tracker.py @@ -157,7 +157,7 @@ class Tracker(Extension): @slash_command( name="add-alert", - description="List all alerts you have signed up for" + description="Add an alert listener" ) async def add_alert(self, ctx: SlashContext): if not await self._users.exists(ctx.user.id): @@ -184,8 +184,10 @@ class Tracker(Extension): else: alert = Alert(alert_type, flavor, user.region) if not await self._users.is_subscribed(user, alert): - await self._users.add_alert(user, alert) - await self._alerts.add_user(alert, user) + await asyncio.gather( + self._users.add_alert(user, alert), + self._alerts.add_user(alert, user) + ) await ctx.send("Successfully added alert", ephemeral=True) else: @@ -197,14 +199,26 @@ class Tracker(Extension): description="Remove an alert you have signed up for" ) async def remove_alert(self, ctx: SlashContext): + if not await self._users.exists(ctx.user.id): + await ctx.send("You are not registered with any region\n" + "Please register with /register before adding alerts", + ephemeral=True) + return user = await self._users.get(ctx.user.id) + alerts = await self._users.list_alerts(user) + if len(alerts) == 0: + await ctx.send("You do not have any alerts registered", ephemeral=True) + return + try: alert = await self.remove_alert_select_menu(ctx, user) except TimeoutError: return else: - await self._users.remove_alert(user, alert) - await self._alerts.remove_user(alert, user) + await asyncio.gather( + self._users.remove_alert(user, alert), + self._alerts.remove_user(alert, user) + ) await ctx.send("Successfully removed alert", ephemeral=True)