aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2020-07-19 22:51:51 +0800
committerGravatar kosayoda <[email protected]>2020-07-19 22:51:51 +0800
commitd658fabaa1238eda9d26175af751e2e8b7f1fc13 (patch)
tree2afed6c290838d7855fdb561c227c6096d71c74e
parentRefactor commands return type (diff)
Remove duplicate mentions from reminder arguments
This also accounts for the author passing themselves to mention, and therefore avoids the user from being told they're not allowed to mention themselves even though they could.
-rw-r--r--bot/cogs/reminders.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/cogs/reminders.py b/bot/cogs/reminders.py
index 1410bfea6..60fa70d74 100644
--- a/bot/cogs/reminders.py
+++ b/bot/cogs/reminders.py
@@ -104,7 +104,7 @@ class Reminders(Cog):
await ctx.send(embed=embed)
@staticmethod
- async def _check_mentions(ctx: Context, mentions: t.List[Mentionable]) -> t.Tuple[bool, str]:
+ async def _check_mentions(ctx: Context, mentions: t.Iterable[Mentionable]) -> t.Tuple[bool, str]:
"""
Returns whether or not the list of mentions is allowed.
@@ -121,7 +121,7 @@ class Reminders(Cog):
return True, ""
@staticmethod
- async def validate_mentions(ctx: Context, mentions: t.List[Mentionable]) -> bool:
+ async def validate_mentions(ctx: Context, mentions: t.Iterable[Mentionable]) -> bool:
"""
Filter mentions to see if the user can mention, and sends a denial if not allowed.
@@ -256,6 +256,10 @@ class Reminders(Cog):
await send_denial(ctx, "You have too many active reminders!")
return
+ # Remove duplicate mentions
+ mentions = set(mentions)
+ mentions.discard(ctx.author)
+
# Filter mentions to see if the user can mention members/roles
if not await self.validate_mentions(ctx, mentions):
return
@@ -374,6 +378,10 @@ class Reminders(Cog):
@edit_reminder_group.command(name="mentions", aliases=("pings",))
async def edit_reminder_mentions(self, ctx: Context, id_: int, mentions: Greedy[Mentionable]) -> None:
"""Edit one of your reminder's mentions."""
+ # Remove duplicate mentions
+ mentions = set(mentions)
+ mentions.discard(ctx.author)
+
# Filter mentions to see if the user can mention members/roles
if not await self.validate_mentions(ctx, mentions):
return