21 lines
665 B
JavaScript
21 lines
665 B
JavaScript
require('dotenv').config();
|
|
const fs = require('node:fs');
|
|
const { REST } = require('@discordjs/rest');
|
|
const { Routes } = require('discord-api-types/v9');
|
|
|
|
const commands = [];
|
|
const commandFiles = fs.readdirSync('./src/commands');
|
|
|
|
for (const file of commandFiles) {
|
|
const command = require(`./src/commands/${file}`);
|
|
commands.push(command.data.toJSON());
|
|
}
|
|
|
|
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN);
|
|
|
|
rest
|
|
.put(Routes.applicationGuildCommands(process.env.BOT_CLIENT_ID, process.env.BOT_GUILD_ID), {
|
|
body: commands,
|
|
})
|
|
.then(() => console.log('Successfully registered application commands.'))
|
|
.catch(console.error);
|