fix(aurora): make Shortmute.handler() take an int for interval instead of str
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 22s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 43s

This commit is contained in:
cswimr 2025-02-18 15:06:40 -06:00
parent 6977647758
commit 44108774e1
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087

View file

@ -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()