26 lines
No EOL
700 B
JavaScript
26 lines
No EOL
700 B
JavaScript
import 'dotenv/config';
|
|
import { REST, Routes } from 'discord.js';
|
|
import fs from 'fs';
|
|
|
|
const commands = [];
|
|
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
|
|
|
for (const file of commandFiles) {
|
|
const command = await import(`./commands/${file}`);
|
|
commands.push(command.default.data.toJSON());
|
|
}
|
|
|
|
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
|
|
|
(async () => {
|
|
try {
|
|
console.log('Enregistrement des commandes slash...');
|
|
await rest.put(
|
|
Routes.applicationCommands(process.env.CLIENT_ID),
|
|
{ body: commands },
|
|
);
|
|
console.log('Commandes enregistrées ! Tape /funfact sur Discord.');
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
})(); |