Skip to content

Commit

Permalink
refactor: Update command registration to v14
Browse files Browse the repository at this point in the history
  • Loading branch information
octfx committed Sep 4, 2023
1 parent c257d20 commit e7cf058
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions deploy-commands.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('node:fs');
const path = require('node:path');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token, local } = require('./config.json');

const commands = [];
Expand All @@ -11,10 +10,14 @@ const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
commands.push(command.data.toJSON());
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}

const rest = new REST({ version: '9' }).setToken(token);
const rest = new REST().setToken(token);

if (local === true) {
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
Expand Down

0 comments on commit e7cf058

Please sign in to comment.