diff options
| author | 2019-09-12 15:18:14 +0200 | |
|---|---|---|
| committer | 2019-09-12 15:18:14 +0200 | |
| commit | 874cc1ba111e23973198773a2e4f14392e9c0fff (patch) | |
| tree | 18e69edc6b585d91396cc51366a22f51bbb96e4d | |
| parent | Fixed incorrect API request field in superstarify (diff) | |
Fix AntiSpam incorrectly invoking tempmute.
https://github.com/python-discord/bot/issues/400
The AntiSpam punish method incorrectly invoked the tempmute
command, as it provided an unconverted duration argument. Since
direct invocation of commands bypasses converters, the conversion
of the duration string to a datetime object is now done manually.
Closes #400
| -rw-r--r-- | bot/cogs/antispam.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py index 6104ec08b..02d5d64ce 100644 --- a/bot/cogs/antispam.py +++ b/bot/cogs/antispam.py @@ -14,6 +14,7 @@ from bot.constants import ( Guild as GuildConfig, Icons, STAFF_ROLES, ) +from bot.converters import ExpirationDate log = logging.getLogger(__name__) @@ -37,6 +38,7 @@ class AntiSpam: self.bot = bot role_id = AntiSpamConfig.punishment['role_id'] self.muted_role = Object(role_id) + self.expiration_date_converter = ExpirationDate() @property def mod_log(self) -> ModLog: @@ -130,8 +132,9 @@ class AntiSpam: ping_everyone=AntiSpamConfig.ping_everyone ) - # Run a tempmute - await mod_log_ctx.invoke(Moderation.tempmute, member, f"{remove_role_after}S", reason=reason) + # Since we're going to invoke the tempmute command directly, we need to manually call the converter. + dt_remove_role_after = await self.expiration_date_converter.convert(mod_log_ctx, f"{remove_role_after}S") + await mod_log_ctx.invoke(Moderation.tempmute, member, dt_remove_role_after, reason=reason) async def maybe_delete_messages(self, channel: TextChannel, messages: List[Message]): # Is deletion of offending messages actually enabled? |