bug fixes

This commit is contained in:
2025-10-10 18:51:23 -04:00
parent 8236c1e0e7
commit 61ab1e1d9e
15 changed files with 4463 additions and 7 deletions

View File

@@ -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);