diff --git a/modules/moderation/ban.py b/modules/moderation/ban.py index 0867d69..1894316 100644 --- a/modules/moderation/ban.py +++ b/modules/moderation/ban.py @@ -18,6 +18,7 @@ class Ban(commands.Cog): @commands.hybrid_command(name="ban") @commands.has_permissions(ban_members=True) + @commands.bot_has_permissions(ban_members=True) @commands.guild_only() async def ban( self, @@ -86,6 +87,7 @@ class Ban(commands.Cog): @commands.hybrid_command(name="unban") @commands.has_permissions(ban_members=True) + @commands.bot_has_permissions(ban_members=True) @commands.guild_only() async def unban( self, diff --git a/modules/moderation/cases.py b/modules/moderation/cases.py index a29730b..292d107 100644 --- a/modules/moderation/cases.py +++ b/modules/moderation/cases.py @@ -47,10 +47,26 @@ class Cases(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - @commands.hybrid_command(name="case", aliases=["c", "ca"], description="View a specific case by number") + @commands.hybrid_command(name="case", aliases=["c", "ca"]) @commands.has_permissions(manage_messages=True) @commands.guild_only() - async def view_case_by_number(self, ctx: commands.Context[commands.Bot], case_number: int) -> None: + async def view_case_by_number( + self, + ctx: commands.Context[commands.Bot], + case_number: int | None = None, + ) -> None: + """ + View a specific case by number or all cases if no number is provided. + + Parameters + ---------- + case_number: int | None + The case number to view. If None, view all cases. + """ + if case_number is None: + await ctx.invoke(self.view_all_cases_in_guild) + return + guild_id = ctx.guild.id if ctx.guild else 0 case = case_service.fetch_case_by_guild_and_number(guild_id, case_number) @@ -75,10 +91,21 @@ class Cases(commands.Cog): ) await ctx.send(embed=embed) - @commands.hybrid_command(name="cases", description="View all cases in the guild") + @commands.hybrid_command(name="cases") @commands.has_permissions(manage_messages=True) @commands.guild_only() - async def view_all_cases_in_guild(self, ctx: commands.Context[commands.Bot]) -> None: + async def view_all_cases_in_guild( + self, + ctx: commands.Context[commands.Bot], + ) -> None: + """ + View all cases in the guild. + + Parameters + ---------- + ctx: commands.Context[commands.Bot] + The context of the command. + """ if not ctx.guild: raise LumiException(CONST.STRINGS["error_not_in_guild"]) @@ -107,10 +134,22 @@ class Cases(commands.Cog): await menu.start() - @commands.hybrid_command(name="modcases", aliases=["mc", "modc"], description="View all cases in the guild") + @commands.hybrid_command(name="modcases", aliases=["mc", "modc"]) @commands.has_permissions(manage_messages=True) @commands.guild_only() - async def view_all_cases_by_mod(self, ctx: commands.Context[commands.Bot], moderator: discord.Member) -> None: + async def view_all_cases_by_mod( + self, + ctx: commands.Context[commands.Bot], + moderator: discord.Member, + ) -> None: + """ + View all cases by a specific moderator. + + Parameters + ---------- + moderator: discord.Member + The moderator to view cases for. + """ if not ctx.guild: raise LumiException(CONST.STRINGS["error_not_in_guild"]) @@ -139,10 +178,26 @@ class Cases(commands.Cog): await menu.start() - @commands.hybrid_command(name="editcase", aliases=["ec"], description="Edit the reason for a case") + @commands.hybrid_command(name="editcase", aliases=["ec"]) @commands.has_permissions(manage_messages=True) @commands.guild_only() - async def edit_case_reason(self, ctx: commands.Context[commands.Bot], case_number: int, *, new_reason: str): + async def edit_case_reason( + self, + ctx: commands.Context[commands.Bot], + case_number: int, + *, + new_reason: str, + ) -> None: + """ + Edit the reason for a specific case. + + Parameters + ---------- + case_number: int + The case number to edit. + new_reason: str + The new reason for the case. + """ if not ctx.guild: raise LumiException(CONST.STRINGS["error_not_in_guild"]) diff --git a/modules/moderation/kick.py b/modules/moderation/kick.py index f0a854b..d537bff 100644 --- a/modules/moderation/kick.py +++ b/modules/moderation/kick.py @@ -15,10 +15,27 @@ class Kick(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - @commands.hybrid_command(name="kick", description="Kick a user") + @commands.hybrid_command(name="kick", aliases=["k"]) @commands.has_permissions(kick_members=True) + @commands.bot_has_permissions(kick_members=True) @commands.guild_only() - async def kick(self, ctx: commands.Context[commands.Bot], target: discord.Member, *, reason: str | None = None): + async def kick( + self, + ctx: commands.Context[commands.Bot], + target: discord.Member, + *, + reason: str | None = None, + ) -> None: + """ + Kick a user from the guild. + + Parameters + ---------- + target: discord.Member + The user to kick. + reason: str | None + The reason for the kick. Defaults to None. + """ assert ctx.guild assert ctx.author assert ctx.bot.user diff --git a/modules/moderation/slowmode.py b/modules/moderation/slowmode.py index 2e56469..87bf0f1 100644 --- a/modules/moderation/slowmode.py +++ b/modules/moderation/slowmode.py @@ -56,15 +56,26 @@ class Slowmode(commands.Cog): @commands.command( name="slowmode", aliases=["sm"], - usage="slowmode ", ) @commands.has_permissions(manage_channels=True) + @commands.bot_has_permissions(manage_channels=True) + @commands.guild_only() async def slowmode( self, ctx: commands.Context[commands.Bot], arg1: str | None = None, arg2: str | None = None, ) -> None: + """ + Set or view the slowmode for a channel. + + Parameters + ---------- + arg1: str | None + The first argument. Defaults to None. + arg2: str | None + The second argument. Defaults to None. + """ channel, duration = None, None for arg in (arg1, arg2): @@ -83,15 +94,26 @@ class Slowmode(commands.Cog): @app_commands.command( name="slowmode", - description="Set or view the slowmode for a channel", ) @app_commands.checks.has_permissions(manage_channels=True) + @app_commands.checks.bot_has_permissions(manage_channels=True) + @app_commands.guild_only() async def slowmode_slash( self, interaction: discord.Interaction, channel: discord.TextChannel, duration: str | None = None, ) -> None: + """ + Set or view the slowmode for a channel. + + Parameters + ---------- + channel: discord.TextChannel + The channel to set the slowmode for. + duration: str | None + The duration of the slowmode. Defaults to None. + """ await self._set_slowmode(interaction, channel, duration)