diff --git a/aurora/aurora.py b/aurora/aurora.py index dfe49e7..cbc0936 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -513,6 +513,7 @@ class Aurora(commands.Cog): Why are you setting the slowmode?""" if channel is None: channel = interaction.channel + assert channel is not None await self.moderate( ctx=interaction, diff --git a/aurora/models/moderation_types.py b/aurora/models/moderation_types.py index 9db3b3b..ffc058d 100644 --- a/aurora/models/moderation_types.py +++ b/aurora/models/moderation_types.py @@ -155,7 +155,7 @@ class AddRole(Type): content=error("There are no whitelisted roles set for this server!"), ephemeral=True, ) - return + return None if duration is not None: try: @@ -171,14 +171,14 @@ class AddRole(Type): if role.id not in addrole_whitelist: await ctx.send(content=error("That role isn't whitelisted!"), ephemeral=True) - return + return None if role.id in [user_role.id for user_role in target.roles]: await ctx.send( content=error(f"{target.mention} already has this role!"), ephemeral=True, ) - return + return None response = await ctx.send(content=f"{target.mention} has {cls.embed_desc}{role.mention} role{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time else ''}!\n**Reason** - `{reason}`") @@ -320,7 +320,7 @@ class RemoveRole(Type): content=error("There are no whitelisted roles set for this server!"), ephemeral=True, ) - return + return None if duration is not None: try: @@ -336,14 +336,14 @@ class RemoveRole(Type): if role.id not in addrole_whitelist: await ctx.send(content=error("That role isn't whitelisted!"), ephemeral=True) - return + return None if role.id not in [user_role.id for user_role in target.roles]: await ctx.send( content=error(f"{target.mention} does not have this role!"), ephemeral=True, ) - return + return None response = await ctx.send(content=f"{target.mention} has {cls.embed_desc}{role.mention} role removed{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time else ''}!\n**Reason** - `{reason}`") @@ -482,16 +482,16 @@ class Mute(Type): allowed_mentions=AllowedMentions(users=False), ephemeral=True, ) - return + return None try: parsed_time = parse_timedelta(duration, maximum=timedelta(days=28)) if parsed_time is None: await ctx.send(error("Please provide a valid duration!"), ephemeral=True) - return + return None except commands.BadArgument: await ctx.send(error("Please provide a duration that is less than 28 days."), ephemeral=True) - return + return None await target.timeout(parsed_time, reason=f"Muted by {ctx.author.id} for: {reason}") @@ -679,7 +679,7 @@ class Ban(Type): try: await ctx.guild.fetch_ban(target) await ctx.send(content=error(f"{target.mention} is already {cls.verb}!"), ephemeral=True) - return + return None except NotFound: pass @@ -743,7 +743,7 @@ class Tempban(Ban): try: await ctx.guild.fetch_ban(target) await ctx.send(content=error(f"{target.mention} is already {Ban.verb}!"), ephemeral=True) - return + return None except NotFound: pass @@ -901,7 +901,7 @@ class Unban(Type): await ctx.guild.fetch_ban(target) except NotFound: await ctx.send(content=error(f"{target.mention} is not {Ban.verb}!"), ephemeral=True) - return + return None response_message = await ctx.send(f"{target.mention} has been {cls.verb}!\n{bold('Reason:')} {inline(reason)}") @@ -930,25 +930,26 @@ class Slowmode(Type): return None @classmethod - async def handler(cls, ctx: commands.Context, target: Messageable, silent: bool, duration: str, reason: str) -> "Slowmode": # pylint: disable=unused-argument + async def handler(cls, ctx: commands.Context, target: Messageable, silent: bool, duration: str | None, reason: str, interval: str) -> "Slowmode": # pylint: disable=unused-argument """Set the slowmode in a channel.""" bot = ctx.bot try: - parsed_time = parse_relativedelta(argument=duration) + parsed_time = parse_relativedelta(argument=interval) if parsed_time is None: - raise commands.BadArgument() + 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: - await ctx.send(content=error(text="The slowmode duration cannot exceed 6 hours!"), ephemeral=True) + 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())) - 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=parsed_time, reason=None) + 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}) 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()