From 078210b54c27a0598acfaed5f6ea6eb19b97f8b5 Mon Sep 17 00:00:00 2001 From: Bakersbakebread <29239704+Bakersbakebread@users.noreply.github.com> Date: Fri, 8 Nov 2019 14:43:21 +0000 Subject: [PATCH] change to_check.guild to getattr() (#3101) * change to_check.guild to getattr() * add webhook check * changelog * Update changelog.d/3100.bugfix.rst Co-Authored-By: Michael H --- changelog.d/3100.bugfix.rst | 1 + redbot/core/bot.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog.d/3100.bugfix.rst diff --git a/changelog.d/3100.bugfix.rst b/changelog.d/3100.bugfix.rst new file mode 100644 index 000000000..53e3797b4 --- /dev/null +++ b/changelog.d/3100.bugfix.rst @@ -0,0 +1 @@ +fix ``is_automod_immune`` handling of guild check and support for checking webhooks diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 796ed7a27..a7becdf73 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -653,7 +653,7 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: d ``True`` if immune """ - guild = to_check.guild + guild = getattr(to_check, "guild", None) if not guild: return False @@ -666,7 +666,8 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: d except AttributeError: # webhook messages are a user not member, # cheaper than isinstance - return True # webhooks require significant permissions to enable. + if author.bot and author.discriminator == "0000": + return True # webhooks require significant permissions to enable. else: ids_to_check.append(author.id)