2023-01-18 00:35:24 +00:00
|
|
|
// dotenv for handling environment variables
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
dotenv.config();
|
|
|
|
|
2023-01-19 01:10:05 +00:00
|
|
|
const { REST, Routes } = require('discord.js');
|
2023-01-19 17:44:49 +00:00
|
|
|
const { guildId } = require('../data/config.json');
|
2023-01-18 00:35:24 +00:00
|
|
|
const clientId = process.env.clientId;
|
|
|
|
const token = process.env.TOKEN;
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const commands = [];
|
2023-01-19 17:44:49 +00:00
|
|
|
const commandFiles = fs.readdirSync('../slash-commands').filter(file => file.endsWith('.js'));
|
2023-01-18 00:35:24 +00:00
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
2023-01-19 17:44:49 +00:00
|
|
|
const command = require(`../slash-commands/${file}`);
|
2023-01-18 00:35:24 +00:00
|
|
|
if (command.data != undefined) {
|
|
|
|
commands.push(command.data.toJSON());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(commands);
|
|
|
|
|
2023-01-19 01:10:05 +00:00
|
|
|
const rest = new REST({ version: '10' }).setToken(token);
|
2023-01-18 00:35:24 +00:00
|
|
|
|
|
|
|
(async () => {
|
|
|
|
try {
|
|
|
|
console.log('Started refreshing application (/) commands.');
|
|
|
|
|
|
|
|
await rest.put(
|
|
|
|
Routes.applicationGuildCommands(clientId, guildId),
|
|
|
|
{ body: commands },
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log('Successfully reloaded application (/) commands.');
|
|
|
|
process.exit();
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
})();
|