From 31d5f8139c2709f3297b848b767105bf8a3a728c Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 9 Apr 2022 21:28:21 -0400 Subject: [PATCH] New Module to Clear Channel Messages --- modules/ClearChannelMessages/cog.py | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/ClearChannelMessages/cog.py diff --git a/modules/ClearChannelMessages/cog.py b/modules/ClearChannelMessages/cog.py new file mode 100644 index 0000000..e902035 --- /dev/null +++ b/modules/ClearChannelMessages/cog.py @@ -0,0 +1,31 @@ +from discord.ext import commands +import asyncio + + +class ClearMessages(commands.Cog): + def __init__(self, bot): + self.Bot = bot + + @commands.command() + async def clear(self, ctx, amount=0): + if amount == 0: + fail = await ctx.send("Please enter an amount to delete!") + await asyncio.sleep(6) + await fail.delete() + + if amount < 3: + await ctx.channel.purge(limit=amount) + sucess = await ctx.send( + f"{amount} messages has been deleted ") # sending success msg + await asyncio.sleep(6) # wait 6 seconds + await sucess.delete() # deleting the success msg + + else: + if amount == 0: + fail = await ctx.send("Please enter an amount to delete!") + await asyncio.sleep(6) + await fail.delete() + + +def setup(bot: commands.Bot): + bot.add_cog(ClearMessages(bot))