diff options
author | 2020-02-26 16:09:04 -0500 | |
---|---|---|
committer | 2020-02-26 16:09:04 -0500 | |
commit | 063c3058fbc0f2c7eb1da3cdc80e76865cb7ad0b (patch) | |
tree | 387eaa343a3228082a60577d0037932099f73dbc | |
parent | Disable TRACE logging for Sentry breadcrumbs. (diff) | |
parent | Add clarifying comment to role checking logic implementation (diff) |
Merge pull request #790 from ks129/master
Added ignoring staff to Antimalware check.
-rw-r--r-- | bot/cogs/antimalware.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/cogs/antimalware.py b/bot/cogs/antimalware.py index 28e3e5d96..9e9e81364 100644 --- a/bot/cogs/antimalware.py +++ b/bot/cogs/antimalware.py @@ -4,7 +4,7 @@ from discord import Embed, Message, NotFound from discord.ext.commands import Cog from bot.bot import Bot -from bot.constants import AntiMalware as AntiMalwareConfig, Channels, URLs +from bot.constants import AntiMalware as AntiMalwareConfig, Channels, STAFF_ROLES, URLs log = logging.getLogger(__name__) @@ -18,7 +18,13 @@ class AntiMalware(Cog): @Cog.listener() async def on_message(self, message: Message) -> None: """Identify messages with prohibited attachments.""" - if not message.attachments: + # Return when message don't have attachment and don't moderate DMs + if not message.attachments or not message.guild: + return + + # Check if user is staff, if is, return + # Since we only care that roles exist to iterate over, check for the attr rather than a User/Member instance + if hasattr(message.author, "roles") and any(role.id in STAFF_ROLES for role in message.author.roles): return embed = Embed() |