From fc78522ad357025dca4781f46af350d2837f09c7 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sun, 21 Apr 2024 08:34:20 -0700 Subject: [PATCH] Fixing the purge and cleanup commands --- app/cogs/server_utils.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index 67bed8a0..76174887 100755 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -185,28 +185,24 @@ class ServerUtils(commands.Cog): await ctx.channel.purge(limit=int(count), check=is_me) - response = await ctx.respond("ok") - await response.delete() + await ctx.respond("ok", delete_after=2) - @commands.command(name="cleanup") - async def cleanup(self, ctx: commands.Context): + @commands.slash_command( + guild_ids=None, name="cleanup", description="cleanup bot messages" + ) + @commands.has_role("ADMIN") + @option( + name="count", + description="The count to delete", + default=3, + required=True, + ) + async def cleanup(self, ctx: commands.Context, count): def is_discord_bot(m): return m.author == self.bot.user - num = 20 - if len(ctx.message.content.split()) > 1: - try: - num = int(ctx.message.content.split()[1]) + 1 - except ValueError: - await ctx.send( - ctx.message.channel, - "You need to give me a number, you entered {}".format( - ctx.message.content.split()[1] - ), - ) - return - await ctx.message.channel.purge(limit=num, check=is_discord_bot) - await ctx.message.delete() + await ctx.channel.purge(limit=count, check=is_discord_bot) + await ctx.respond("ok", delete_after=2) @commands.command(name="shoo") async def shoo(self, ctx: commands.Context):