diff options
| author | 2019-09-12 13:32:05 +0200 | |
|---|---|---|
| committer | 2019-09-12 13:36:37 +0200 | |
| commit | 6bf86152b9eefc09e65d79537074f64904e04e04 (patch) | |
| tree | d0bd33994f30e7f8c7fc9e488e984f207199b32c | |
| parent | Merge pull request #402 from python-discord/update-contrib (diff) | |
Fixed AntiSpam cog reload bug
https://github.com/python-discord/bot/issues/411
The AntiSpam code suffered from a bug where the attribute
self.muted_role was not defined after reloading the cog. The
bug was caused by the cog setting the attribute in on_ready
instead of directly in __init__. Fixed by setting the attribute
in the __init__.
Closes #411
| -rw-r--r-- | bot/cogs/antispam.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py index 0c6a02bf9..6104ec08b 100644 --- a/bot/cogs/antispam.py +++ b/bot/cogs/antispam.py @@ -12,7 +12,7 @@ from bot.constants import ( AntiSpam as AntiSpamConfig, Channels, Colours, DEBUG_MODE, Event, Filter, Guild as GuildConfig, Icons, - Roles, STAFF_ROLES, + STAFF_ROLES, ) @@ -35,16 +35,13 @@ RULE_FUNCTION_MAPPING = { class AntiSpam: def __init__(self, bot: Bot): self.bot = bot - self._muted_role = Object(Roles.muted) + role_id = AntiSpamConfig.punishment['role_id'] + self.muted_role = Object(role_id) @property def mod_log(self) -> ModLog: return self.bot.get_cog("ModLog") - async def on_ready(self): - role_id = AntiSpamConfig.punishment['role_id'] - self.muted_role = Object(role_id) - async def on_message(self, message: Message): if ( not message.guild |