// code from goatstore // api: https://store.agi.bd "use strict"; module.exports = { config: { name: "help2", aliases: ["menu2", "hmenu"], version: "3.0.0", author: "saju_islam", countDown: 0, role: 0, category: "system", shortDescription: { en: "Premium smart command center" }, description: { en: "Stylish paginated command menu" }, guide: { en: "{pn} [command/page]" } }, onStart: async function ({ message, args, prefix }) { try { const commandMap = global.GoatBot?.commands; if (!commandMap || typeof commandMap.values !== "function") { return message.reply("❌ Command list unavailable."); } const allCommands = Array.from(commandMap.values()) .filter(cmd => cmd && cmd.config && cmd.config.name); const argText = Array.isArray(args) ? args.join(" ").trim() : String(args || "").trim(); const pfx = String(prefix || "."); // Normalize category names const normalizeCategory = value => String(value || "OTHER").trim().toUpperCase() || "OTHER"; // COMMAND SEARCH if (argText && !/^page\s+\d+$/i.test(argText)) { const searchName = argText.split(/\s+/)[0].toLowerCase(); const found = allCommands.find(cmd => { const cfg = cmd.config; const name = String(cfg.name).toLowerCase(); const aliases = Array.isArray(cfg.aliases) ? cfg.aliases.map(a => String(a).toLowerCase()) : []; return name === searchName || aliases.includes(searchName); }); if (!found) { return message.reply( `╭━━〔 🔎 COMMAND SEARCH 〕━━╮\n` + `┃\n` + `┃ ✘ Command not found\n` + `┃ ✦ Search: ${searchName}\n` + `┃\n` + `┃ Use ${pfx}help2\n` + `┃ Example: ${pfx}help2 baby\n` + `╰━━━━━━━━━━━━━━━━━━╯` ); } const cfg = found.config; const aliases = Array.isArray(cfg.aliases) ? cfg.aliases.join(", ") || "None" : "None"; const description = cfg.description?.en || cfg.shortDescription?.en || "No description available."; const guide = typeof cfg.guide === "string" ? cfg.guide : cfg.guide?.en || `${pfx}${cfg.name}`; const info = `╭━━〔 👑 COMMAND PROFILE 〕━━╮\n` + `┃\n` + `┃ ✦ NAME: ${cfg.name}\n` + `┃ ✦ ALIAS: ${aliases}\n` + `┃ ✦ VERSION: ${cfg.version || "N/A"}\n` + `┃ ✦ AUTHOR: ${cfg.author || "Unknown"}\n` + `┃ ✦ ROLE: ${cfg.role ?? 0}\n` + `┃ ✦ CATEGORY: ${normalizeCategory(cfg.category)}\n` + `┃\n` + `┣━━〔 ✨ DESCRIPTION 〕━━\n` + `┃ ${description}\n` + `┃\n` + `┣━━〔 📖 HOW TO USE 〕━━\n` + `┃ ${guide}\n` + `┃\n` + `╰━━━━━━━━━━━━━━━━━━╯\n` + ` ✦ 𝐒𝐀𝐉𝐔 𝐁𝐎𝐓 ✦`; return message.reply(info); } // MERGE CATEGORIES const categoryMap = new Map(); for (const cmd of allCommands) { const cfg = cmd.config; const category = normalizeCategory(cfg.category); const name = String(cfg.name).trim(); if (!name) continue; if (!categoryMap.has(category)) { categoryMap.set(category, new Map()); } // Deduplicate command names within category categoryMap.get(category).set(name.toLowerCase(), name); } const categories = Array.from(categoryMap.keys()) .sort((a, b) => a.localeCompare(b)); const totalCategories = categories.length; const totalCommands = allCommands.length; // Build compact category blocks const blocks = []; for (const category of categories) { const names = Array.from(categoryMap.get(category).values()) .sort((a, b) => a.localeCompare(b)); const lines = []; for (let i = 0; i < names.length; i += 2) { const left = names[i]; const right = names[i + 1]; let line = `┃ ${left}`; if (right) { line += ` ✧ ${right}`; } lines.push(line); } const block = `╭━━〔 📂 ${category} • ${names.length} 〕\n` + `${lines.join("\n")}\n` + `╰━━━━━━━━━━━━━━━━━━╯`; blocks.push(block); } // Pagination const maxPageChars = 2600; const pages = []; let current = ""; for (const block of blocks) { const next = current ? current + "\n\n" + block : block; if (current && next.length > maxPageChars) { pages.push(current); current = block; } else { current = next; } } if (current) pages.push(current); if (pages.length === 0) { pages.push("No commands available."); } const totalPages = pages.length; const pageMatch = argText.match(/^page\s+(\d+)$/i); const requestedPage = pageMatch ? Number(pageMatch[1]) : 1; const page = Number.isSafeInteger(requestedPage) ? Math.max(1, Math.min(requestedPage, totalPages)) : 1; // PREMIUM HEADER const header = `╭━━━〔 👑 𝐒𝐀𝐉𝐔 𝐁𝐎𝐓 〕━━━╮\n` + `┃\n` + `┃ ✦ 𝐏𝐑𝐎 𝐂𝐎𝐌𝐌𝐀𝐍𝐃 𝐂𝐄𝐍𝐓𝐄𝐑 ✦\n` + `┃\n` + `┣━━━━━━━━━━━━━━━━━━\n` + `┃ 💎 COMMANDS : ${totalCommands}\n` + `┃ 📂 CATEGORIES : ${totalCategories}\n` + `┃ ⚡ PREFIX : ${pfx}\n` + `┃ 📄 PAGE : ${page}/${totalPages}\n` + `┣━━━━━━━━━━━━━━━━━━\n\n`; // QUICK GUIDE const footer = `\n\n╭━━━〔 ⚡ QUICK GUIDE 〕━━━╮\n` + `┃\n` + `┃ ✧ ${pfx}help2\n` + `┃ All commands\n` + `┃\n` + `┃ ✧ ${pfx}help2 baby\n` + `┃ Command details\n` + `┃\n` + `┃ ✧ ${pfx}help2 page 2\n` + `┃ Open page 2\n` + `┃\n` + `┣━━━━━━━━━━━━━━━━━━\n` + `┃ ✦ STAY SMART • STAY ROYAL\n` + `╰━━━━━━━━━━━━━━━━━━╯`; const pageInfo = `\n\n╭━━━━━━━━━━━━━━━━━━╮\n` + `┃ ◈ PAGE ${page}/${totalPages}\n` + `┃ NEXT: ${pfx}help2 page ${page < totalPages ? page + 1 : 1}\n` + `╰━━━━━━━━━━━━━━━━━━╯`; let output = header + pages[page - 1]; const gifURLs = [ "https://i.imgur.com/Xw6JTfn.gif", "https://i.imgur.com/mW0yjZb.gif", "https://i.imgur.com/KQBcxOV.gif" ]; // Avoid oversized footer if ((output + footer).length < 5000) { output += footer; } else { output += pageInfo; } return message.reply(output); } catch (err) { console.error("[HELP2 PREMIUM ERROR]", err); return message.reply( "❌ Help2 error. Please check the bot console." ); } } };