const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, ButtonBuilder, ButtonStyle, MessageFlags, SeparatorSpacingSize, } = require('discord.js'); const { ContainerBuilder, SectionBuilder, TextDisplayBuilder, ThumbnailBuilder, SeparatorBuilder, } = require('@discordjs/builders'); module.exports = { ownerOnly: true, data: new SlashCommandBuilder() .setName("help2") .setDescription("Displays all commands categorized.") .setDefaultMemberPermissions(0), async execute(interaction, client) { await interaction.deferReply(); const featuresCategories = []; const advancedCategories = []; const mainContainer = new ContainerBuilder() .setAccentColor(0x0647E0) .addSectionComponents( new SectionBuilder() .addTextDisplayComponents( new TextDisplayBuilder().setContent( `# <:mainmenu:1318204877582766090>Main Menu\n` + `**${process.env.BotName}** is a Discord Bot that offers various features to enhance your server experience. Invite **${process.env.BotName}** to your server and enjoy 24/7 uptime with systems like moderation, giveaways, games, YouTube notifications, and role management.\n\n` + `**Join ${process.env.ServerName}:** [Click Here](https://discord.gg/${process.env.vanityURL})\n` + `**Website:** [Visit](https://drayv-nexcoder.pages.dev/)\n` + `**Vote & Review:** [Top.gg](https://top.gg/bot/1281896325490933880?s=09754f82b19dc)\n` + `**Invite ${process.env.BotName}:** [Invite Link](https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands)` ) ) .setThumbnailAccessory( new ThumbnailBuilder().setURL(client.user.displayAvatarURL({ dynamic: true })) ) ) .addSeparatorComponents(new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Large)) .addSectionComponents( new SectionBuilder().addTextDisplayComponents( new TextDisplayBuilder().setContent( "<:thunder:1318205017907531787> __**Features**__\n" + "<:shields:1318204958038032445> Automod\n" + "<:hammer:1318204689652912211> Moderation\n" + "<:community:1318204611668082699> Community\n" + "<:reaction:1318204901385441310> Reaction Roles\n" + "<:games:1362341645051498646> Games\n" + "<:fun:1362341396769542217> Fun\n" + "<:info:1318204713115582515> Info System\n" + "<:report:1318204611668082699> Report System\n" + "<:auditlog:1318204580890284062> Server Logs\n" + "<:music:1318227667337871391> Sound System\n" + "<:sticky:1318204976128065649> Sticky Messages\n" + "<:security:1389485457129341099> Security" ) ) ) .addSeparatorComponents(new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Large)) .addSectionComponents( new SectionBuilder().addTextDisplayComponents( new TextDisplayBuilder().setContent( "<:thunder:1318205017907531787> __**Advanced Features**__\n" + "<:jointocreate:1318204837887868978> Join2Create\n" + "<:giveaway:1318204669314732032> Giveaway\n" + "<:epicgames:1318204631666524240> Epic Games System\n" + "<:youtube:1318205083317567509> YouTube & Twitch Notifications\n" + "<:verified:1362338419551768806> Verification System\n" + "<:ticket:1318205034411982920> Ticket System\n" + "<:welcome2:1318218574623408180> Welcome System\n" + "<:booster:1362339723535716495> Server Booster System\n" + "<:bye_badge:1350139753907097742> Leave System\n" + "<:invitelogger:1318204733206560819> Invite Logger System\n" + "<:leveling:1318204857970331680> Leveling System\n" + "<:aibot:1330571429216911480> AI Chat Bot" ) ) ) .addActionRowComponents( new ActionRowBuilder().addComponents( new StringSelectMenuBuilder() .setCustomId("features-menu") .setPlaceholder("📋 Select a Feature") .addOptions( featuresCategories.map((category, index) => ({ label: category.title, value: `feature_${index}`, description: `View commands for ${category.title}`, emoji: category.emoji ? { name: category.emoji } : undefined, })) ) ) ) .addActionRowComponents( new ActionRowBuilder().addComponents( new StringSelectMenuBuilder() .setCustomId("advanced-menu") .setPlaceholder("⚡ Select an Advanced Feature") .addOptions( advancedCategories.map((category, index) => ({ label: category.title, value: `advanced_${index}`, description: `View commands for ${category.title}`, emoji: category.emoji ? { name: category.emoji } : undefined, })) ) ) ); await interaction.editReply({ components: [mainContainer], flags: MessageFlags.IsComponentsV2, }); const filter = i => i.user.id === interaction.user.id; const collector = interaction.channel.createMessageComponentCollector({ filter, time: 120000 }); let currentPage = 0; let currentCategory = null; let currentType = null; collector.on("collect", async i => { try { const [type, indexStr] = i.values ? i.values[0].split("_") : [null, null]; if (i.customId === "features-menu" || i.customId === "advanced-menu") { currentCategory = (i.customId === "features-menu" ? featuresCategories : advancedCategories)[parseInt(indexStr, 10)]; currentType = i.customId === "features-menu" ? "features" : "advanced"; currentPage = 0; await showCategoryPage(i, currentCategory, currentPage, currentType); } else if (["prev-page", "next-page", "back-main"].includes(i.customId)) { if (i.customId === "prev-page") { currentPage = Math.max(0, currentPage - 1); } else if (i.customId === "next-page") { const maxPage = Math.ceil(currentCategory.commands.length / 7) - 1; currentPage = Math.min(maxPage, currentPage + 1); } else if (i.customId === "back-main") { currentCategory = null; currentType = null; return i.update({ components: [mainContainer] }); } await showCategoryPage(i, currentCategory, currentPage, currentType); } } catch (error) { console.error("Error handling interaction:", error); } }); async function showCategoryPage(i, category, page, type) { const commandsPerPage = 7; const start = page * commandsPerPage; const end = start + commandsPerPage; const pageCommands = category.commands.slice(start, end); const totalPages = Math.ceil(category.commands.length / commandsPerPage); const categoryContainer = new ContainerBuilder() .setAccentColor(0x0647E0) .addSectionComponents( new SectionBuilder() .addTextDisplayComponents( new TextDisplayBuilder().setContent( `${category.emoji} __**${category.title} Commands**__\n\n` + pageCommands.map(cmd => `**📝 /${cmd.name}**\n<:curveline:1318223962756354058> ${cmd.value}`).join("\n\n") ) ) .setThumbnailAccessory( new ThumbnailBuilder().setURL(client.user.displayAvatarURL({ dynamic: true })) ) ) .addSeparatorComponents(new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Large)) .addActionRowComponents( new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("prev-page") .setLabel("◀ Previous") .setStyle(ButtonStyle.Secondary) .setDisabled(page === 0), new ButtonBuilder() .setCustomId("back-main") .setLabel("🏠 Back to Menu") .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId("next-page") .setLabel("Next ▶") .setStyle(ButtonStyle.Secondary) .setDisabled(page >= totalPages - 1) ) ); await i.update({ components: [categoryContainer], flags: MessageFlags.IsComponentsV2, }); } collector.on("end", async () => { try { const expiredContainer = new ContainerBuilder().addTextDisplayComponents( new TextDisplayBuilder().setContent("This help menu has expired. Please run the command again.") ); await interaction.editReply({ flags: MessageFlags.IsComponentsV2, components: [expiredContainer], }); } catch (error) { console.error("Error ending collector:", error); } }); }, };