goat
command
help
Show all commands
0
views
0
likes
0
installs
Aliases: menu, commands
raw source
const fs = require("fs-extra");
const path = require("path");
const axios = require("axios");
module.exports = {
config: {
name: "help",
aliases: ["menu", "commands"],
version: "7.0",
author: "EfxAsif",
shortDescription: "Show all commands",
longDescription: "Show all commands in clean UI with random GIF/video",
category: "system",
guide: "{pn}help [command name]"
},
onStart: async function ({ message, args, prefix }) {
const allCommands = global.GoatBot.commands;
// ==============================
// Fancy Font
// ==============================
const fancyFont = (str) =>
str.replace(/[A-Za-z]/g, (c) => {
const map = {
A:"๐",B:"๐",C:"๐",D:"๐",E:"๐",F:"๐
",G:"๐",H:"๐",
I:"๐",J:"๐",K:"๐",L:"๐",M:"๐",N:"๐",O:"๐",P:"๐",
Q:"๐",R:"๐",S:"๐",T:"๐",U:"๐",V:"๐",W:"๐",X:"๐",
Y:"๐",Z:"๐",
a:"๐",b:"๐",c:"๐",d:"๐",e:"๐",f:"๐",g:"๐ ",h:"๐ก",
i:"๐ข",j:"๐ฃ",k:"๐ค",l:"๐ฅ",m:"๐ฆ",n:"๐ง",o:"๐จ",p:"๐ฉ",
q:"๐ช",r:"๐ซ",s:"๐ฌ",t:"๐ญ",u:"๐ฎ",v:"๐ฏ",w:"๐ฐ",x:"๐ฑ",
y:"๐ฒ",z:"๐ณ"
};
return map[c] || c;
});
// ==============================
// Category Font
// ==============================
const categoryFont = (str) =>
str
.split("")
.map((c) => {
const map = {
A:"๐",B:"๐",C:"๐",D:"๐",E:"๐",F:"๐
",G:"๐",H:"๐",
I:"๐",J:"๐",K:"๐",L:"๐",M:"๐",N:"๐",O:"๐",P:"๐",
Q:"๐",R:"๐",S:"๐",T:"๐",U:"๐",V:"๐",W:"๐",X:"๐",
Y:"๐",Z:"๐"
};
return map[c] || c;
})
.join("");
const cleanCategoryName = (text) =>
text ? text.toLowerCase() : "others";
// ==============================
// Specific Command Help
// ==============================
if (args[0]) {
const cmdName = args[0].toLowerCase();
const cmd =
allCommands.get(cmdName) ||
[...allCommands.values()].find(
(c) => c.config.aliases?.includes(cmdName)
);
if (!cmd) {
return message.reply(
`โ ${fancyFont(`Command '${cmdName}' not found!`)}
โค Try ${prefix}help to see full list`
);
}
const usage =
typeof cmd.config.guide === "string"
? cmd.config.guide.replace("{pn}", cmd.config.name)
: cmd.config.name;
const infoMsg =
`โโโโโโโโโโโโโโโ
๐งฉ ๐๐๐ ๐๐๐
๐
โโโโโโโโโโโโโโโ
โฆ Name : ${cmd.config.name}
โฆ Aliases : ${cmd.config.aliases?.join(", ") || "None"}
โฆ Category : ${categoryFont(
(cmd.config.category || "Others").toUpperCase()
)}
โฆ Version : v${cmd.config.version || "1.0"}
โฆ Author : ${cmd.config.author || "Unknown"}
โฆ Usage : ${prefix}${usage}
โโโโโโโโโโโโโโโ
๐ ${
cmd.config.longDescription ||
cmd.config.shortDescription ||
"No description"
}`;
return message.reply(infoMsg);
}
// ==============================
// Build Categories
// ==============================
const categories = {};
for (const [name, cmd] of allCommands) {
const cat = cleanCategoryName(cmd.config.category);
if (!categories[cat]) {
categories[cat] = [];
}
categories[cat].push(name);
}
// ==============================
// Main Help Message
// ==============================
let msg =
`โญโ ๐๐๐๐๐๐๐๐ ๐๐๐๐
โ Prefix : ${prefix}
โ Total : ${allCommands.size}
โ Author : EfxAsif
`;
for (const cat of Object.keys(categories).sort()) {
const catTitle = categoryFont(cat.toUpperCase());
msg += `\nโโ ${catTitle} โโ\n`;
for (const cmdName of categories[cat].sort()) {
msg += `โ โ ${fancyFont(cmdName)}\n`;
}
msg += `โโโโโโโโโโโโโโโ\n`;
}
msg += `\nโฐโ Use: ${prefix}help <command>`;
// ==============================
// GIF + GOOGLE DRIVE VIDEOS
// ==============================
const mediaList = [
// Existing GIFs
{
type: "gif",
url: "https://i.imgur.com/Xw6JTfn.gif",
name: "help_gif_1.gif"
},
{
type: "gif",
url: "https://i.imgur.com/mW0yjZb.gif",
name: "help_gif_2.gif"
},
{
type: "gif",
url: "https://i.imgur.com/KQBcxOV.gif",
name: "help_gif_3.gif"
},
// Google Drive Video 1
{
type: "video",
url: "https://drive.google.com/file/d/1xzRHlnlnf_QRNkI0hnTssEAlACF0t0gc/view?usp=drivesdk",
id: "1xzRHlnlnf_QRNkI0hnTssEAlACF0t0gc",
name: "help_video_1.mp4"
},
// Google Drive Video 2
{
type: "video",
url: "https://drive.google.com/file/d/1G6p87ApW-5taGZ8J81QKKSjyBTPABO8S/view?usp=drivesdk",
id: "1G6p87ApW-5taGZ8J81QKKSjyBTPABO8S",
name: "help_video_2.mp4"
}
];
// ==============================
// Random Media
// ==============================
const randomMedia =
mediaList[Math.floor(Math.random() * mediaList.length)];
// ==============================
// Cache Folder
// ==============================
const mediaFolder = path.join(__dirname, "cache");
await fs.ensureDir(mediaFolder);
const mediaPath = path.join(
mediaFolder,
randomMedia.name
);
try {
// ==============================
// Download If Not Cached
// ==============================
if (!fs.existsSync(mediaPath)) {
let downloadURL = randomMedia.url;
// Convert Google Drive view URL
// into direct download URL
if (randomMedia.type === "video") {
downloadURL =
`https://drive.usercontent.google.com/download?id=${randomMedia.id}&export=download&confirm=t`;
}
await downloadMedia(
downloadURL,
mediaPath
);
}
// ==============================
// Send Media
// ==============================
return message.reply({
body: msg,
attachment: fs.createReadStream(mediaPath)
});
} catch (error) {
console.error(
"[HELP MEDIA ERROR]",
error.message
);
// If media fails, still show help menu
return message.reply(
`${msg}
โ ๏ธ Media could not be loaded.
Please try ${prefix}help again.`
);
}
}
};
// ======================================
// Download Media Function
// ======================================
async function downloadMedia(url, destination) {
const response = await axios({
method: "GET",
url: url,
responseType: "stream",
maxRedirects: 10,
timeout: 120000,
headers: {
"User-Agent":
"Mozilla/5.0 (Android 13; Mobile) AppleWebKit/537.36 Chrome/120 Safari/537.36"
}
});
if (response.status !== 200) {
throw new Error(
`Download failed with status ${response.status}`
);
}
const writer =
fs.createWriteStream(destination);
return new Promise((resolve, reject) => {
response.data.pipe(writer);
writer.on("finish", () => {
writer.close();
resolve();
});
writer.on("error", (err) => {
fs.unlink(destination).catch(() => {});
reject(err);
});
response.data.on("error", (err) => {
fs.unlink(destination).catch(() => {});
reject(err);
});
});
}