DLAP/deploy-command.js

20 lines
746 B
JavaScript
Raw Normal View History

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'}
const { clientID, token } = JSON.parse(readFileSync('./config.json'));
const commands = [];
const commandFiles = fs.readdirSync('./Commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const { default: command } = await import(`./Commands/${file}`);
2022-07-09 22:14:38 -04:00
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '10' }).setToken(token);
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);