goat
command
help
Show all commands
0
views
0
likes
0
installs
Aliases: menu
raw source
const fs = require("fs-extra");
const path = require("path");
const https = require("https");
// --- Fonts ---
const smallCapsMap = {
a:'แด', b:'ส', c:'แด', d:'แด
', e:'แด', f:'๊ฐ',
g:'ษข', h:'ส', i:'ษช', j:'แด', k:'แด', l:'ส',
m:'แด', n:'ษด', o:'แด', p:'แด', q:'วซ', r:'ส',
s:'๊ฑ', t:'แด', u:'แด', v:'แด ', w:'แดก', x:'x',
y:'ส', z:'แดข'
};
const cmdFontMap = {
...smallCapsMap,
'0':'โฐ','1':'ยน','2':'ยฒ','3':'ยณ','4':'โด',
'5':'โต','6':'โถ','7':'โท','8':'โธ','9':'โน'
};
const toSmallCaps = t =>
t.toLowerCase().split("").map(c => smallCapsMap[c] || c).join("");
const toCmdFont = t =>
t.toLowerCase().split("").map(c => cmdFontMap[c] || c).join("");
module.exports = {
config: {
name: "help",
aliases: ["menu"],
version: "6.0",
author: "๐๐๐๐๐๐",
shortDescription: "Show all commands",
longDescription: "Full command list with video",
category: "system",
guide: "{pn}help [command]"
},
onStart: async function ({ message, args, prefix }) {
const allCommands = global.GoatBot.commands;
const categories = {};
const cleanCategoryName = (text) => {
if (!text) return "OTHERS";
return text
.normalize("NFKD")
.replace(/[^\w\s-]/g, "")
.replace(/\s+/g, " ")
.trim()
.toUpperCase();
};
// --- organize commands ---
for (const [, cmd] of allCommands) {
if (!cmd?.config || cmd.config.name === "help") continue;
const cat = cleanCategoryName(cmd.config.category);
if (!categories[cat]) categories[cat] = [];
categories[cat].push(cmd.config.name);
}
// --- video list ---
const videoURLs = [
"https://i.imgur.com/IJOTdkf.mp4",
"https://i.imgur.com/amKPt9x.mp4",
"https://i.imgur.com/Aj0skDe.mp4",
"https://i.imgur.com/2mRF8gL.mp4",
"https://i.imgur.com/AMv8IqG.mp4",
"https://i.imgur.com/mUpxBMI.mp4",
"https://i.imgur.com/dhcx6pW.mp4",
"https://i.imgur.com/SF4abeL.mp4",
"https://i.imgur.com/qw9KVTY.mp4"
];
const cacheDir = path.join(__dirname, "cache");
if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, { recursive: true });
const indexFile = path.join(cacheDir, "help_video_index.json");
let index = 0;
if (fs.existsSync(indexFile)) {
try {
index = (JSON.parse(fs.readFileSync(indexFile)).index + 1) % videoURLs.length;
} catch {}
}
fs.writeFileSync(indexFile, JSON.stringify({ index }));
const videoPath = path.join(cacheDir, `help_video_${index}.mp4`);
if (!fs.existsSync(videoPath)) {
await downloadFile(videoURLs[index], videoPath);
}
// --- single command ---
if (args[0]) {
const query = args[0].toLowerCase();
const cmd =
allCommands.get(query) ||
[...allCommands.values()].find(c =>
(c.config?.aliases || []).map(a => a.toLowerCase()).includes(query)
);
if (!cmd || !cmd.config) {
return message.reply(`โ Command "${query}" not found.`);
}
const {
name,
version,
category,
shortDescription,
longDescription,
aliases,
guide
} = cmd.config;
const desc =
typeof longDescription === "string"
? longDescription
: longDescription?.en ||
shortDescription?.en ||
shortDescription ||
"No description";
const usage =
(typeof guide === "string"
? guide
: guide?.en || `{pn}${name}`)
.replace(/{pn}/g, prefix);
return message.reply({
body:
`๐ธ COMMAND INFO ๐ธ\n\n` +
`๐ Name: ${name}\n\n` +
`๐ Category: ${category || "None"}\n\n` +
`๐ Description: ${desc}\n\n` +
`๐ Aliases: ${aliases?.length ? aliases.join(", ") : "None"}\n\n` +
`๐ Usage: ${usage}\n\n` +
`๐ Author: ๐๐๐๐๐๐\n\n` +
`๐ Version: ${version || "1.0"}`,
attachment: fs.createReadStream(videoPath)
});
}
// --- full menu ---
let msg = "โโโโโโโโโโโโโโโโ๐ฌ\nโ ๐๐ ARIYAN BOT CMDS ๐๐\nโโโโโโโโโโโโโโโโ๐ฌ\n\n\n";
const sortedCategories = Object.keys(categories).sort();
for (const cat of sortedCategories) {
msg += `โญโโโ๐ ๐ ${toSmallCaps(cat)} ๐\n`;
const commands = categories[cat].sort();
for (let i = 0; i < commands.length; i += 2) {
const a = toCmdFont(commands[i]);
const b = commands[i + 1] ? toCmdFont(commands[i + 1]) : null;
msg += b ? `โโฌ ${a} โฌ ${b}\n` : `โโฌ ${a}\n`;
}
msg += `โโโโโโโโโโโโโ๐ฌ\n\n`;
}
msg +=
`โโโโโโโโโโโโโโโโ๐ฌ\n` +
` ๐๐๐ Total Commands: ${allCommands.size - 1}\n` +
` ๐๐๐ Prefix: ${prefix}\n` +
` ๐๐๐ Owner: ARIYAN\n` +
`โโโโโโโโโโโโโโโโ๐ฌ`;
return message.reply({
body: msg,
attachment: fs.createReadStream(videoPath)
});
}
};
// --- downloader ---
function downloadFile(url, dest) {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(dest);
https.get(url, res => {
if (res.statusCode !== 200) {
fs.unlink(dest, () => {});
return reject();
}
res.pipe(file);
file.on("finish", () => file.close(resolve));
}).on("error", err => {
fs.unlink(dest, () => {});
reject(err);
});
});
}