2022-07-09 22:14:38 -04:00
|
|
|
import fs, { readFileSync } from 'node:fs';
|
|
|
|
import { REST } from '@discordjs/rest';
|
|
|
|
import { Routes } from 'discord-api-types/v10';
|
|
|
|
// import config from './config.json' assert {type: 'json'}
|
2022-07-12 19:49:42 -04:00
|
|
|
const { clientID, token } = JSON.parse(readFileSync('./config.json'));
|
2022-03-26 13:43:03 -04:00
|
|
|
|
|
|
|
const commands = [];
|
2022-12-18 22:31:04 -05:00
|
|
|
const commandFiles = fs.readdirSync('./Commands').filter(file => file.endsWith('.js'));
|
2022-03-26 13:43:03 -04:00
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
2022-12-18 22:31:04 -05:00
|
|
|
const { default: command } = await import(`./Commands/${file}`);
|
2022-07-09 22:14:38 -04:00
|
|
|
commands.push(command.data.toJSON());
|
2022-03-26 13:43:03 -04:00
|
|
|
}
|
|
|
|
|
2022-07-12 19:49:42 -04:00
|
|
|
const rest = new REST({ version: '10' }).setToken(token);
|
2022-03-26 13:43:03 -04:00
|
|
|
|
2022-07-12 19:49:42 -04:00
|
|
|
rest.put(Routes.applicationCommands(clientID), { body: commands })
|
2022-07-09 22:14:38 -04:00
|
|
|
.then(() => console.log('Successfully registered application commands.'))
|
|
|
|
.catch(console.error);
|