import os import aiohttp from discord.ext import commands import discord DISCORD_TOKEN = os.getenv("DISCORD_TOKEN") CLIENT_ID = os.getenv("CLIENT_ID") bot = commands.Bot(command_prefix="!", intents=discord.Intents.all) @bot.command() async def delete_all_commands(ctx): if ctx.author.guild_permissions.administrator: headers = { "Authorization": f"Bot {DISCORD_TOKEN}" } async with aiohttp.ClientSession() as session: async with session.delete(f"https://discord.com/api/v9/applications/{CLIENT_ID}/commands", headers=headers) as resp: if resp.status == 200: await ctx.send("All global slash commands deleted successfully.") else: await ctx.send(f"Failed to delete global slash commands. Status code: {resp.status}") else: await ctx.send("You do not have permission to delete slash commands.") bot.run(DISCORD_TOKEN)