mirror of
https://github.com/Alee14/DLAP.git
synced 2025-01-22 19:02:57 -05:00
19 lines
768 B
JavaScript
19 lines
768 B
JavaScript
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 config = 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}`);
|
|
commands.push(command.data.toJSON());
|
|
}
|
|
|
|
const rest = new REST({ version: '10' }).setToken(config.token);
|
|
|
|
rest.put(Routes.applicationGuildCommands(config.clientID, config.guildID), { body: commands })
|
|
.then(() => console.log('Successfully registered application commands.'))
|
|
.catch(console.error);
|