diff --git a/payphone/cogs/admin/cog.py b/payphone/cogs/admin/cog.py index a1ed515..12e31de 100644 --- a/payphone/cogs/admin/cog.py +++ b/payphone/cogs/admin/cog.py @@ -175,12 +175,12 @@ class Admin(base.Cog): embed=embeds.report_embed(report), view=views.ReportView(self.bot, report) ) - @commands.command(aliases=["bs"]) + @commands.command(aliases=["bs", "ws"]) @checks.is_moderator() - async def bans( + async def record( self, ctx: commands.Context, user: discord.User | int | None = None ) -> None: - """Shows all bans of a specific user. + """Shows all bans and warns of a specific user. Options: - `[user]`: The user to show the bans of. @@ -339,6 +339,85 @@ class Admin(base.Cog): author_check=True, ).send(ctx) + @commands.command(aliases=["rmw"]) + @checks.is_moderator() + async def remove_warning(self, ctx: commands.Context, warn_id: int) -> None: + """Delete a specific warning. + + Options: + - ``: The ID of the warning to delete. + + Permissions: + - Bot Moderator + """ + + warn = await models.Warn.get_or_none(id=warn_id) + + if warn is None: + return await ctx.send("❌ Warning not found.") + + await models.User.filter(id=warn.user_id).update( + warns_count=models.User.warns_count - 1 + ) + + await warn.delete() + + await ctx.send( + f"✅ Deleted warning #{warn.id} for user <@{warn.user_id}>.", + allowed_mentions=discord.AllowedMentions(users=False), + ) + + @commands.command(aliases=["rmb"]) + @checks.is_moderator() + async def remove_ban(self, ctx: commands.Context, ban_id: int) -> None: + """Delete a specific ban. + + Options: + - ``: The ID of the ban to delete. + + Permissions: + - Bot Moderator + """ + + ban = await models.Ban.get_or_none(id=ban_id) + + if ban is None: + return await ctx.send("❌ Ban not found.") + + await models.User.filter(id=ban.user_id).update( + bans_count=models.User.bans_count - 1 + ) + + await ban.delete() + + await ctx.send( + f"✅ Deleted ban #{ban.id} for user <@{ban.user_id}>.", + allowed_mentions=discord.AllowedMentions(users=False), + ) + + @commands.command(aliases=["clr"]) + @checks.is_moderator() + async def clear_record( + self, ctx: commands.Context, user: discord.User | int | None = None + ) -> None: + """Clears the record of a user. + + Options: + - `[user]`: The user, their ID, or the author of the command if none is specified. + + Permissions: + - Bot Moderator + """ + + await models.User.filter(id=user.id).update(bans_count=0, warns_count=0) + await models.Ban.filter(user_id=user.id).delete() + await models.Warn.filter(user_id=user.id).delete() + + await ctx.send( + f"✅ Cleared the record of <@{user.id}>.", + allowed_mentions=discord.AllowedMentions(users=False), + ) + def setup(bot: Payphone) -> None: """Loads the Admin cog into the bot.