const { ApplicationCommandOptionType } = require('discord.js'); const db = require("../mongoDB"); module.exports = { name: "help", description: "It helps you get information about the bot and commands.", permissions: "0x0000000000000800", options: [ { name: "info", description: "The command you want to get information about.", type: ApplicationCommandOptionType.String, required: false, }, ], showHelp: true, // Set to true to display in help run: async (client, interaction) => { let lang = await db?.musicbot?.findOne({ guildID: interaction.guild.id }); lang = lang?.language || client.language; lang = require(`../languages/${lang}.js`); try { const { EmbedBuilder } = require('discord.js'); const info = interaction.options.getString('info'); if (info) { // Look for a specific command and its tags const cmd_filter = client.commands.find((cmd) => cmd.name === info); if (!cmd_filter) return interaction.reply({ content: lang.msg127, ephemeral: true }).catch(e => { }); const tags = cmd_filter.tags || []; // Check if tags are defined const tagsString = tags.length > 0 ? tags.join(', ') : 'No tags'; const embed = new EmbedBuilder() .setTitle(`Command Info: ${cmd_filter.name}`) .setDescription(`> **Description: \`${cmd_filter.description}\`**\n> **Tags: ${tagsString}**`) .setColor(client.config.embedColor) .setTimestamp(); return interaction.reply({ embeds: [embed] }).catch(e => { }); } else { const tagsToDisplay = ["music", "mod", "other"]; // Add your desired tags here const embed = new EmbedBuilder() .setColor(client.config.embedColor) .setTitle("Musi's Help GUI") .setDescription(lang.msg32) .setTimestamp() .setFooter({ text: "https://musibot.lag.tf" }); // Fix the error tagsToDisplay.forEach((tag) => { const taggedCommands = client.commands.filter((cmd) => { const tags = cmd.tags || []; // Check if tags are defined return cmd.showHelp && tags.includes(tag); }); if (taggedCommands.size > 0) { const tagCommandsString = taggedCommands.map((cmd) => `\`/${cmd.name}\``).join(' \n '); embed.addField(tag, tagCommandsString); } }); interaction.reply({ embeds: [embed] }).catch(e => { }); } } catch (e) { const errorNotifier = require("../functions.js"); errorNotifier(client, interaction, e, lang); } }, };