import discord from discord.ext import commands class Channel(commands.Cog): def __init__(self, bot): self.bot = bot @commands.slash_command(name="clear_channel", description="Permanently delete all messages in a channel", guild_ids=[681414775468589180]) @commands.has_permissions(manage_messages=True) async def clear_channel(self, ctx: discord.ApplicationContext): progress = await ctx.respond("Deleting all messages in this channel...", ephemeral=True) channel = ctx.channel # Fetch all messages in the channel async for message in channel.history(limit=None): try: await message.delete() except discord.Forbidden: await ctx.send("I do not have permission to delete messages.") return except discord.HTTPException: await ctx.send("Failed to delete a message.") return await progress.edit(content="✔ All messages deleted successfully! ✔") def setup(bot): bot.add_cog(Channel(bot))