File size: 912 Bytes
1a26fbe
12e0b84
1a26fbe
421cf0e
 
12e0b84
421cf0e
12e0b84
1a26fbe
 
12e0b84
 
 
 
 
 
 
 
 
 
 
99d64f1
12e0b84
421cf0e
12e0b84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import aiohttp
from discord.ext import commands

DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
CLIENT_ID = os.getenv("CLIENT_ID")

bot = commands.Bot(command_prefix="!")

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