From 44108774e121b4de9ab7a86e58d133ac557e862a Mon Sep 17 00:00:00 2001 From: cswimr Date: Tue, 18 Feb 2025 15:06:40 -0600 Subject: [PATCH] fix(aurora): make `Shortmute.handler()` take an `int` for `interval` instead of `str` --- aurora/models/moderation_types.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/aurora/models/moderation_types.py b/aurora/models/moderation_types.py index ffc058d..cc6eafb 100644 --- a/aurora/models/moderation_types.py +++ b/aurora/models/moderation_types.py @@ -930,26 +930,17 @@ class Slowmode(Type): return None @classmethod - async def handler(cls, ctx: commands.Context, target: Messageable, silent: bool, duration: str | None, reason: str, interval: str) -> "Slowmode": # pylint: disable=unused-argument + async def handler(cls, ctx: commands.Context, target: Messageable, silent: bool, duration: str | None, reason: str, interval: int) -> "Slowmode": # pylint: disable=unused-argument """Set the slowmode in a channel.""" bot = ctx.bot - try: - parsed_time = parse_relativedelta(argument=interval) - if parsed_time is None: - raise commands.BadArgument - parsed_time = timedelta_from_relativedelta(relativedelta=parsed_time) - except (commands.BadArgument, ValueError): - await ctx.send(content=error(text="Please provide a valid duration!"), ephemeral=True) - return cls() - - if ceil(parsed_time.total_seconds()) > 21600: + if ceil(interval) > 21600: await ctx.send(content=error(text="The slowmode interval cannot exceed 6 hours!"), ephemeral=True) return cls() if isinstance(target, TextChannel): - await target.edit(slowmode_delay=ceil(parsed_time.total_seconds())) + await target.edit(slowmode_delay=ceil(interval)) assert ctx.guild - moderation = await Moderation.log(bot=bot, guild_id=ctx.guild.id, moderator_id=ctx.author.id, moderation_type=cls(), target_type="channel", target_id=target.id, role_id=None, duration=None, reason=reason, metadata={"interval": parsed_time}) + moderation = await Moderation.log(bot=bot, guild_id=ctx.guild.id, moderator_id=ctx.author.id, moderation_type=cls(), target_type="channel", target_id=target.id, role_id=None, duration=None, reason=reason, metadata={"interval": interval}) await ctx.send(content=f"{ctx.author.mention} has {cls.verb} {target.mention} to {humanize_timedelta(timedelta=parsed_time)}!\n{bold(text='Reason:')} {inline(text=reason)}") await log(ctx=ctx, moderation_id=moderation.id) return cls()