From 874cc1ba111e23973198773a2e4f14392e9c0fff Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Thu, 12 Sep 2019 15:18:14 +0200 Subject: 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 --- bot/cogs/antispam.py | 7 +++++-- 1 file 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? -- cgit v1.2.3