discord-bot-template/modules/_clear-commands.js

28 lines
673 B
JavaScript
Raw Normal View History

2023-01-21 04:35:03 +00:00
// dotenv for handling environment variables
const dotenv = require('dotenv');
dotenv.config();
2023-02-13 04:51:17 +00:00
const { REST, Routes } = require('discord.js');
const botId = process.env.BOTID;
2023-01-21 04:35:03 +00:00
const token = process.env.TOKEN;
2023-02-13 04:51:17 +00:00
const fs = require('fs');
2023-01-21 04:35:03 +00:00
2023-02-13 04:51:17 +00:00
console.log(`Token: ...${token.slice(-5)} | Bot ID: ${botId}`);
const rest = new REST({ version: '10' }).setToken(token);
2023-01-21 04:35:03 +00:00
(async () => {
try {
2023-02-13 04:51:17 +00:00
console.log('Started clearing global application (/) commands.');
2023-01-21 04:35:03 +00:00
await rest.put(
2023-02-13 04:51:17 +00:00
Routes.applicationCommands(botId),
2023-01-21 04:35:03 +00:00
{ body: '' },
);
2023-02-13 04:51:17 +00:00
console.log('Successfully cleared global application (/) commands.');
2023-01-21 04:35:03 +00:00
process.exit();
} catch (error) {
console.error(error);
}
})();