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 <michael@michaelhall.tech>
This commit is contained in:
Bakersbakebread 2019-11-08 14:43:21 +00:00 committed by Michael H
parent e2c8b11008
commit 078210b54c
2 changed files with 4 additions and 2 deletions

View File

@ -0,0 +1 @@
fix ``is_automod_immune`` handling of guild check and support for checking webhooks

View File

@ -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,6 +666,7 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: d
except AttributeError:
# webhook messages are a user not member,
# cheaper than isinstance
if author.bot and author.discriminator == "0000":
return True # webhooks require significant permissions to enable.
else:
ids_to_check.append(author.id)