bug fixes
This commit is contained in:
@@ -12,11 +12,27 @@ for (const file of commandFiles) {
|
||||
const command = require(filePath);
|
||||
if (command.enabled === false || command.dev === true) continue;
|
||||
|
||||
if (command.builder) {
|
||||
if (command.builder) {
|
||||
try {
|
||||
// Some command modules export builder as a function (builder => builder...) or as an instance
|
||||
if (typeof command.builder === 'function') {
|
||||
// create a temporary SlashCommandBuilder by requiring it from discord.js
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const built = command.builder(new SlashCommandBuilder());
|
||||
if (built && typeof built.toJSON === 'function') commands.push(built.toJSON());
|
||||
else commands.push({ name: command.name, description: command.description });
|
||||
} else if (command.builder && typeof command.builder.toJSON === 'function') {
|
||||
commands.push(command.builder.toJSON());
|
||||
} else {
|
||||
} else {
|
||||
commands.push({ name: command.name, description: command.description });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`Failed to build command ${command.name}:`, e && e.message ? e.message : e);
|
||||
commands.push({ name: command.name, description: command.description });
|
||||
}
|
||||
} else {
|
||||
commands.push({ name: command.name, description: command.description });
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN);
|
||||
|
||||
Reference in New Issue
Block a user