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))