goat
command
help
Shows all commands or details.
0
views
0
likes
0
installs
Aliases: menu
raw source
const axios = require("axios");
const { getPrefix } = global.utils;
const { commands, aliases } = global.GoatBot;
let xfont = null;
let yfont = null;
let categoryEmoji = null;
async function loadResources() {
try {
const [catRes, cmdRes, emojiRes] = await Promise.all([
axios.get("https://raw.githubusercontent.com/Saim-x69x/sakura/main/xfont.json"),
axios.get("https://raw.githubusercontent.com/Saim-x69x/sakura/main/yfont.json"),
axios.get("https://raw.githubusercontent.com/Saim-x69x/sakura/main/category.json")
]);
xfont = catRes.data;
yfont = cmdRes.data;
categoryEmoji = emojiRes.data;
} catch (err) {}
}
function fontConvert(text, type = "command") {
const fontMap = type === "category" ? xfont : yfont;
if (!fontMap) return text;
return text.split("").map(ch => fontMap[ch] || ch).join("");
}
function getCategoryEmoji(cat) {
return categoryEmoji?.[cat.toLowerCase()] || "๐๏ธ";
}
function levenshteinDistance(a, b) {
const matrix = Array(b.length + 1).fill(0).map(() => Array(a.length + 1).fill(0));
for (let i = 0; i <= a.length; i++) matrix[0][i] = i;
for (let j = 0; j <= b.length; j++) matrix[j][0] = j;
for (let j = 1; j <= b.length; j++) {
for (let i = 1; i <= a.length; i++) {
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
matrix[j][i] = Math.min(
matrix[j][i - 1] + 1,
matrix[j - 1][i] + 1,
matrix[j - 1][i - 1] + cost
);
}
}
return matrix[b.length][a.length];
}
function getClosestCommand(name) {
const lower = name.toLowerCase();
let best = null, dist = Infinity;
for (const cmd of commands.keys()) {
const d = levenshteinDistance(lower, cmd.toLowerCase());
if (d < dist) {
dist = d;
best = cmd;
}
}
return dist <= 3 ? best : null;
}
function roleTextToString(role) {
switch (role) {
case 0: return "All Users";
case 1: return "Group Admins";
case 2: return "VIP Users";
case 3: return "Bot Admin";
case 4: return "Bot Creator";
default: return "Unknown";
}
}
module.exports = {
config: {
name: "help",
aliases: "menu",
version: "2.0",
author: "rocky404",
countDown: 5,
role: 0,
shortDescription: { en: "Shows all commands or details." },
longDescription: { en: "Display categories, command lists or specific command info." },
category: "info",
guide: { en: "{pn}, {pn} [command], {pn} -c [category]" }
},
onStart: async function ({ message, args, event, role }) {
const prefix = getPrefix(event.threadID);
if (!xfont || !yfont || !categoryEmoji) await loadResources();
const categories = {};
for (const [name, cmd] of commands) {
if (!cmd?.config || typeof cmd.onStart !== "function") continue;
if (cmd.config.role > role) continue;
const cat = (cmd.config.category || "UNCATEGORIZED").toUpperCase();
if (!categories[cat]) categories[cat] = [];
categories[cat].push(name);
}
const helpImage = "https://files.catbox.moe/uoljwh.mp4";
const input = args.join(" ").trim();
if (args[0] === "-c" && args[1]) {
const categoryName = args[1].toUpperCase();
if (!categories[categoryName]) {
return message.reply(`โ Category "${categoryName}" not found.`);
}
const emoji = getCategoryEmoji(categoryName);
const list = categories[categoryName];
const total = list.length;
let msg = "";
msg += "โโโโโโโโโโโโโโ\n";
msg += `๐๐๐๐๐๐๐๐: ${emoji} | ${fontConvert(categoryName, "category")}\n`;
msg += "โญโโโโโโเญจเงโโโโโโโฎ\n";
for (const cmd of list.sort()) {
msg += `โ แฏโง. ${fontConvert(cmd, "command")}\n`;
}
msg += "โโโโโโโเญจเงโโโโโโแฅซแญก\n";
msg += "โข ๐ฝ๐๐๐ ๐๐๐๐ ๐ ๐๐๐ ๐ ๐๐๐๐๐๐๐? ๐๐๐ /๐๐๐๐ <๐๐๐๐๐๐๐๐๐๐๐>.\n";
msg += "โญโโโโโโเญจเงโโโโโโโฎ\n";
msg += `โ ๐ข ๐๐จ๐ญ๐๐ฅ ๐๐จ๐ฆ๐ฆ๐๐ง๐๐ฌ: ${total}\n`;
msg += `โ โก๏ธ ๐๐ซ๐๐๐ข๐ฑ: ${prefix}\n`;
msg += "โ ๐ค ๐๐ซ๐๐๐ญ๐จ๐ซ: JABED\n";
msg += "โฐโโโโโโเญจเงโโโโโโโฏ";
return message.reply({
body: msg,
attachment: await global.utils.getStreamFromURL(helpImage)
});
}
if (!input) {
let msg = "";
msg += "โโโโโโโโโโโโโโ\n";
msg += "๐ฐ๐๐๐๐๐๐๐๐ ๐ฒ๐๐๐๐๐๐๐:\n";
msg += "โโโโโโโโโโโโโโ\n";
for (const cat of Object.keys(categories).sort()) {
msg += `โโโใ ${getCategoryEmoji(cat)} | ${fontConvert(cat, "category")} ใ\n`;
for (const cmd of categories[cat].sort()) {
msg += `โแฏโง. ${fontConvert(cmd, "command")}\n`;
}
msg += "โโโโโโโเญจเงโโโโโโแฅซแญก\n";
}
msg += "โข ๐ฝ๐๐๐ ๐๐๐๐ ๐ ๐๐๐ ๐ ๐๐๐๐๐๐๐? ๐๐๐ /๐๐๐๐ <๐๐๐๐๐๐๐๐๐๐๐>.\n";
msg += "โญโโโโโโเญจเงโโโโโโโฎ\n";
msg += `โ ๐ข ๐๐จ๐ญ๐๐ฅ ๐๐จ๐ฆ๐ฆ๐๐ง๐๐ฌ: ${commands.size}\n`;
msg += `โ โก๏ธ ๐๐ซ๐๐๐ข๐ฑ: ${prefix}\n`;
msg += "โ ๐ค ๐๐ซ๐๐๐ญ๐จ๐ซ: JABED\n";
msg += "โฐโโโโโโเญจเงโโโโโโโฏ";
return message.reply({
body: msg,
attachment: await global.utils.getStreamFromURL(helpImage)
});
}
const cmdName = input.toLowerCase();
const cmd = commands.get(cmdName) || commands.get(aliases.get(cmdName));
if (!cmd || !cmd.config) {
const suggestion = getClosestCommand(cmdName);
return message.reply(
suggestion
? `โ Command "${cmdName}" not found.\n๐ Maybe you meant: ${suggestion}`
: `โ Command "${cmdName}" not found.`
);
}
const c = cmd.config;
const usage = c.guide?.en?.replace(/{pn}/g, `${prefix}${c.name}`) || "No usage.";
const msg = `
โญโโโ [ ๐๐๐๐๐๐๐ ๐๐๐๐ ] โโโโฎ
โ๐งฉ Name : ${c.name}
โ๐ฆ Category : ${(c.category || "UNCATEGORIZED").toUpperCase()}
โ๐ Description: ${c.longDescription?.en || "No description."}
โ๐ Aliases : ${c.aliases ? c.aliases.join(", ") : "None"}
โโ๏ธ Version : ${c.version || "1.0"}
โ๐ Permission : ${c.role} (${roleTextToString(c.role)})
โโฑ๏ธ Cooldown : ${c.countDown || 5}s
โ๐ Author : ${c.author || "Unknown"}
โ๐ Usage : ${usage}
โฐโโโโโโโโโเญจเงโโโโโโโโโโฏ`;
return message.reply(msg);
}
};