Skip to content

Commit

Permalink
[3.4] [Mod] Account for roles in mention spam (Cog-Creators#5388)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3be22b6)

Co-authored-by: Vexed <vex@vexcodes.com>
Co-authored-by: Kowlin <10947836+Kowlin@users.noreply.github.com>
  • Loading branch information
2 people authored and red-githubbot[bot] committed Apr 19, 2023
1 parent 36b75f8 commit 67efee7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions redbot/cogs/mod/events.py
Expand Up @@ -46,12 +46,12 @@ async def check_mention_spam(self, message):
mention_spam = await self.config.guild(guild).mention_spam.all()

if mention_spam["strict"]: # if strict is enabled
mentions = message.raw_mentions
mentions = len(message.raw_mentions) + len(message.raw_role_mentions)
else: # if not enabled
mentions = set(message.mentions)
mentions = len(set(message.mentions)) + len(set(message.role_mentions))

if mention_spam["ban"]:
if len(mentions) >= mention_spam["ban"]:
if mentions >= mention_spam["ban"]:
try:
await guild.ban(author, reason=_("Mention spam (Autoban)"))
except discord.HTTPException:
Expand All @@ -75,7 +75,7 @@ async def check_mention_spam(self, message):
return True

if mention_spam["kick"]:
if len(mentions) >= mention_spam["kick"]:
if mentions >= mention_spam["kick"]:
try:
await guild.kick(author, reason=_("Mention Spam (Autokick)"))
except discord.HTTPException:
Expand All @@ -99,7 +99,7 @@ async def check_mention_spam(self, message):
return True

if mention_spam["warn"]:
if len(mentions) >= mention_spam["warn"]:
if mentions >= mention_spam["warn"]:
try:
await author.send(_("Please do not mass mention people!"))
except (discord.HTTPException, discord.Forbidden):
Expand Down

0 comments on commit 67efee7

Please sign in to comment.