diff --git a/commands/Administrator/auto-role.js b/commands/Administrator/auto-role.js index 72c1820a..627ffe03 100644 --- a/commands/Administrator/auto-role.js +++ b/commands/Administrator/auto-role.js @@ -7,7 +7,7 @@ class AutoRole extends Command { constructor(client) { super(client, { name: 'auto-role', - category: 'Moderation', + category: 'Administrator', description: 'Manage auto-roles in the server.', usage: 'auto-role [role or page]', aliases: ['autorole', 'autoroles'], diff --git a/commands/Giveaways/delete-giveaway.js b/commands/Giveaways/delete-giveaway.js index d27a40c7..14ef35d7 100644 --- a/commands/Giveaways/delete-giveaway.js +++ b/commands/Giveaways/delete-giveaway.js @@ -20,10 +20,6 @@ class DeleteGiveaway extends Command { return this.client.util.errorEmbed(msg, 'You need to have the Manage Messages permission to delete giveaways'); const query = args.join(' '); - const ErrorEmbed = new EmbedBuilder() - .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) - .setColor(msg.settings.embedErrorColor); - if (isNaN(query)) return this.client.util.errorEmbed(msg, msg.settings.prefix + this.help.usage, 'Invalid Message ID'); @@ -41,8 +37,11 @@ class DeleteGiveaway extends Command { msg.channel.send('Giveaway deleted!'); }) .catch((e) => { - ErrorEmbed.setTitle(e); - return msg.channel.send(ErrorEmbed); + const ErrorEmbed = new EmbedBuilder() + .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) + .setColor(msg.settings.embedErrorColor) + .setDescription(e); + return msg.channel.send({ embeds: [ErrorEmbed] }); }); } } diff --git a/commands/Giveaways/end-giveaway.js b/commands/Giveaways/end-giveaway.js index af4359d8..74febc56 100644 --- a/commands/Giveaways/end-giveaway.js +++ b/commands/Giveaways/end-giveaway.js @@ -20,10 +20,6 @@ class EndGiveaway extends Command { const query = args.join(' '); - const ErrorEmbed = new EmbedBuilder() - .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) - .setColor(msg.settings.embedErrorColor); - if (isNaN(query)) return this.client.util.errorEmbed(msg, msg.settings.prefix + this.help.usage, 'Incorrect Usage'); const giveaway = this.client.giveawaysManager.giveaways.find( @@ -40,9 +36,12 @@ class EndGiveaway extends Command { // Success message msg.channel.send('Giveaway ended!'); }) - .catch((e) => { - ErrorEmbed.setTitle(e); - return msg.channel.send(ErrorEmbed); + .catch((error) => { + const ErrorEmbed = new EmbedBuilder() + .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) + .setColor(msg.settings.embedErrorColor) + .setDescription(error); + return msg.channel.send({ embeds: [ErrorEmbed] }); }); } } diff --git a/commands/Giveaways/reroll-giveaway.js b/commands/Giveaways/reroll-giveaway.js index 83f1daef..b6610d9c 100644 --- a/commands/Giveaways/reroll-giveaway.js +++ b/commands/Giveaways/reroll-giveaway.js @@ -19,10 +19,6 @@ class RerollGiveaway extends Command { return this.client.util.errorEmbed(msg, 'You need to have the Manage Messages permission to reroll giveaways'); const query = args.join(''); - const ErrorEmbed = new EmbedBuilder() - .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) - .setColor(msg.settings.embedErrorColor); - if (isNaN(query)) return this.client.util.errorEmbed(msg, msg.settings.prefix + this.help.usage, 'Incorrect Usage'); const giveaway = this.client.giveawaysManager.giveaways.find( @@ -40,7 +36,10 @@ class RerollGiveaway extends Command { msg.channel.send('Giveaway rerolled!'); }) .catch((e) => { - ErrorEmbed.setTitle(e); + const ErrorEmbed = new EmbedBuilder() + .setAuthor({ name: msg.author.tag, iconURL: msg.author.displayAvatarURL() }) + .setColor(msg.settings.embedErrorColor) + .setDescription(e); return msg.channel.send(ErrorEmbed); }); } diff --git a/commands/Owner/export-commands.js b/commands/Owner/export-commands.js new file mode 100644 index 00000000..8f83133b --- /dev/null +++ b/commands/Owner/export-commands.js @@ -0,0 +1,54 @@ +const Command = require('../../base/Command.js'); +const { QuickDB } = require('quick.db'); +const { EmbedBuilder } = require('discord.js'); +const fs = require('fs'); + +class ExportCommands extends Command { + constructor(client) { + super(client, { + name: 'export-commands', + description: 'Exports all commands to a JSON file.', + category: 'General', + usage: 'export-commands', + examples: ['exportcommands'], + aliases: ['exportcmds', 'exportjson'], + }); + } + + async run(msg, args, level) { + const allCommands = this.client.commands; + const commandData = {}; + + allCommands.forEach((cmd) => { + const category = cmd.help.category || 'Unknown'; + const cmdName = cmd.help.name; + + if (!commandData[category]) { + commandData[category] = {}; + } + + commandData[category][cmdName] = { + description: cmd.help.description, + usage: cmd.help.usage, + examples: cmd.help.examples, + aliases: cmd.conf.aliases, + permissionLevel: cmd.conf.permLevel, + guildOnly: cmd.conf.guildOnly, + nsfw: cmd.conf.nsfw, + longDescription: cmd.help.longDescription || 'None', + }; + }); + + const jsonFilePath = './commands.json'; + fs.writeFileSync(jsonFilePath, JSON.stringify(commandData, null, 2), 'utf-8'); + + const embed = new EmbedBuilder() + .setTitle('Commands Exported') + .setDescription(`All commands have been exported to \`${jsonFilePath}\``) + .setColor('#00FF00'); + + msg.channel.send({ embeds: [embed] }); + } +} + +module.exports = ExportCommands;