require("dotenv").config(); const { REST, Routes } = require("discord.js"); const rest = new REST({ version: "10" }) .setToken(process.env.D_TOKEN); async function clearCommands() { try { if (!process.env.D_TOKEN) throw new Error("Missing D_TOKEN environment variable."); if (!process.env.D_ID) throw new Error("Missing D_ID environment variable."); if (!process.env.D_GID) throw new Error("Missing G_GID environment variable."); console.log("Clearing guild application commands..."); await rest.put( Routes.applicationGuildCommands( process.env.D_ID, process.env.D_GID ), { body: [] } ); console.log("Successfully cleared all guild application commands."); } catch (error) { console.error("Failed to clear application commands:"); console.error(error); process.exitCode = 1; } } clearCommands();