Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('node:fs');
- const path = require('node:path');
- const { REST } = require('@discordjs/rest');
- const { Routes } = require('discord-api-types/v9');
- const { clientId, guildId, token } = require('./config.json');
- const commands = [];
- const commandsPath = path.join(__dirname, 'commands');
- const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
- for (const file of commandFiles) {
- const filePath = path.join(commandsPath, file);
- const command = require(filePath)
- commands.push(command.data.toJSON());
- }
- const rest = new REST({ version: '9' }).setToken(token);
- (async () => {
- try {
- console.log('Started refreshing application (/) commands.');
- await rest.put(
- Routes.applicationGuildCommands(clientId, guildId),
- { body: commands },
- );
- console.log('Successfully reloaded application (/) commands.');
- } catch (error) {
- console.error(error);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement