wop's picture
Update app.py
12e0b84 verified
raw
history blame
912 Bytes
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)