aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-07-03 13:11:13 +0100
committerGravatar Gareth Coles <[email protected]>2018-07-03 13:11:13 +0100
commit3b86f8323b0debd5a3548081ab039feee34696ca (patch)
tree6f7a7f913def4a24b6e08aa0cf5395b5ad7e4811
parent[Announcements] User feedback on subscribe/unsubscribe commands (diff)
[Announcements] Feedback if a user already has the relevant state
-rw-r--r--bot/cogs/verification.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py
index d43e795f0..74064305e 100644
--- a/bot/cogs/verification.py
+++ b/bot/cogs/verification.py
@@ -90,13 +90,25 @@ class Verification:
log.trace("No message found, it must have been deleted by another bot.")
@command(name="subscribe", aliases=["subscribe()"])
- @without_role(Roles.announcements)
@in_channel(Channels.bot)
async def subscribe(self, ctx: Context, *_): # We don't actually care about the args
"""
Subscribe to announcement notifications by assigning yourself the role
"""
+ has_role = False
+
+ for role in ctx.author.roles:
+ if role.id == Roles.announcements:
+ has_role = True
+ break
+
+ if has_role:
+ return await ctx.send(
+ f"{ctx.author.mention} You're already subscribed!",
+ delete_after=5
+ )
+
log.debug(f"{ctx.author} called self.subscribe(). Assigning the 'Announcements' role.")
await ctx.author.add_roles(Object(Roles.announcements), reason="Subscribed to announcements")
@@ -113,13 +125,25 @@ class Verification:
)
@command(name="unsubscribe", aliases=["unsubscribe()"])
- @with_role(Roles.announcements)
@in_channel(Channels.bot)
async def unsubscribe(self, ctx: Context, *_): # We don't actually care about the args
"""
Unsubscribe from announcement notifications by removing the role from yourself
"""
+ has_role = False
+
+ for role in ctx.author.roles:
+ if role.id == Roles.announcements:
+ has_role = True
+ break
+
+ if not has_role:
+ return await ctx.send(
+ f"{ctx.author.mention} You're already unsubscribed!",
+ delete_after=5
+ )
+
log.debug(f"{ctx.author} called self.unsubscribe(). Removing the 'Announcements' role.")
await ctx.author.remove_roles(Object(Roles.announcements), reason="Unsubscribed from announcements")