← back to browse
goat command

help

Show all available 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");

// ๐ŸŽฅ Put your direct mp4 video link here (e.g., https://files.catbox.moe/xxxxxx.mp4)
const HELP_VIDEO_URL = "https://files.catbox.moe/euhp0a.mp4";

module.exports = {
	config: {
		name: "help",
		aliases: ["menu", "commands"],
		version: "5.0",
		author: "Protik shah",
		countDown: 3,
		role: 0,
		shortDescription: "Show all available commands",
		longDescription: "Displays a ultra-stylish, categorized list of commands with video attachment support.",
		category: "system",
		guide: "{pn}help [command name]"
	},

	onStart: async function ({ api, message, args, prefix }) {
		const sendMsg = (txt) => message && typeof message.reply === "function" ? message.reply(txt) : api.sendMessage(txt, event.threadID, event.messageID);
		const allCommands = global.GoatBot.commands;
		const categories = {};

		const emojiMap = {
			ai: "๐Ÿค–", "ai-image": "๐ŸŽจ", group: "๐Ÿ‘ฅ", system: "โš™๏ธ",
			fun: "๐ŸŽฎ", owner: "๐Ÿ‘‘", config: "๐Ÿ› ๏ธ", economy: "๐Ÿ’ฐ",
			media: "๐ŸŽฅ", "18+": "๐Ÿ”ž", tools: "๐Ÿงฐ", utility: "๐Ÿ”ง",
			info: "โ„น๏ธ", image: "๐Ÿ–ผ๏ธ", game: "๐ŸŽฒ", admin: "๐Ÿ›ก๏ธ",
			rank: "๐Ÿ†", boxchat: "๐Ÿ’ฌ", others: "๐Ÿ“Œ"
		};

		const cleanCategoryName = (text) => {
			if (!text) return "others";
			return text
				.normalize("NFKD")
				.replace(/[^\w\s-]/g, "")
				.replace(/\s+/g, " ")
				.trim()
				.toLowerCase();
		};

		for (const [name, cmd] of allCommands) {
			const cat = cleanCategoryName(cmd.config.category);
			if (!categories[cat]) categories[cat] = [];
			categories[cat].push(cmd.config.name);
		}

		// Detailed Command Info View
		if (args[0]) {
			const query = args[0].toLowerCase();
			const cmd =
				allCommands.get(query) ||
				[...allCommands.values()].find((c) => (c.config.aliases || []).includes(query));
			if (!cmd) return sendMsg(`โŒ ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ "${query}" ๐—ป๐—ผ๐˜ ๐—ณ๐—ผ๐˜‚๐—ป๐—ฑ.`);

			const {
				name,
				version,
				author,
				guide,
				category,
				shortDescription,
				longDescription,
				aliases,
				role 
			} = cmd.config;

			const desc =
				typeof longDescription === "string"
					? longDescription
					: longDescription?.en || shortDescription?.en || shortDescription || "No description available.";

			const usage =
				typeof guide === "string"
					? guide.replace(/{pn}/g, prefix)
					: guide?.en?.replace(/{pn}/g, prefix) || `${prefix}${name}`;

			const requiredRole = role !== undefined ? role : 0; 
			const roleText = requiredRole === 0 ? "Everyone (Member)" : requiredRole === 1 ? "Group Admin" : "Bot Admin / Owner";

			return sendMsg(
				`โš™๏ธ ๐—ฆ๐—ง๐—ฌ๐—Ÿ๐—œ๐—ฆ๐—› ๐—–๐—ข๐— ๐— ๐—”๐—ก๐—— ๐—œ๐—ก๐—™๐—ข โš™๏ธ\n` +
				`โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n` +
				`๐Ÿ“Œ ๐—ก๐—ฎ๐—บ๐—ฒ: ${name.toUpperCase()}\n` +
				`๐Ÿท๏ธ ๐—–๐—ฎ๐˜๐—ฒ๐—ด๐—ผ๐—ฟ๐˜†: ${(category || "Uncategorized").toUpperCase()}\n` +
				`๐Ÿ“ ๐——๐—ฒ๐˜€๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜๐—ถ๐—ผ๐—ป: ${desc}\n` +
				`๐Ÿ”€ ๐—”๐—น๐—ถ๐—ฎ๐˜€๐—ฒ๐˜€: ${aliases?.length ? aliases.join(", ") : "None"}\n` +
				`๐Ÿ’ก ๐—จ๐˜€๐—ฎ๐—ด๐—ฒ: ${usage}\n` +
				`๐Ÿ”‘ ๐—ฃ๐—ฒ๐—ฟ๐—บ๐—ถ๐˜€๐˜€๐—ถ๐—ผ๐—ป: ${roleText}\n` + 
				`๐Ÿ‘ค ๐—”๐˜‚๐˜๐—ต๐—ผ๐—ฟ: ${author}\n` +
				`๐Ÿš€ ๐—ฉ๐—ฒ๐—ฟ๐˜€๐—ถ๐—ผ๐—ป: v${version}\n` +
				`โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`
			);
		}

		// Main Categorized Help Menu View
		const formatCommands = (cmds) => cmds.sort().map((cmd) => `โ†ฌ ${cmd}`);

		let msg = `โšก ๐——๐—œ๐—”๐—•๐—Ÿ๐—ข ๐— ๐—˜๐—ก๐—จ โšก\n`;
		msg += `โ‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ‡œ\n`;

		const sortedCategories = Object.keys(categories).sort();
		for (const cat of sortedCategories) {
			const emoji = emojiMap[cat] || "โ˜ƒ";
			msg += `\nโ•ญโ”€โ”€โ”€โ†ฑ ${emoji} ${cat.toUpperCase()}โ†ฒ \n`; 
			msg += `${formatCommands(categories[cat]).join("  ")}\n`; 
			msg += `โ•ฐโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ‹™\n`;
		}

		msg += `\nโ‰พโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ‰ฟ\n`;
		msg += `๐Ÿ’ก ๐—จ๐˜€๐—ฒ: ${prefix}help <command_name> for detailed usage.\n`;
		msg += `๐Ÿ“ž ๐—จ๐˜€๐—ฒ: ${prefix}callad to talk directly with my boss DI-ABLO.`;

		// Handle Media Attachment (Video)
		if (HELP_VIDEO_URL && HELP_VIDEO_URL.trim() !== "") {
			const cacheDir = path.join(__dirname, "cache");
			await fs.ensureDir(cacheDir);
			const videoPath = path.join(cacheDir, `help_menu_${Date.now()}.mp4`);

			try {
				const res = await axios({ url: HELP_VIDEO_URL, responseType: "stream" });
				const writer = fs.createWriteStream(videoPath);
				res.data.pipe(writer);

				await new Promise((resolve, reject) => {
					writer.on("finish", resolve);
					writer.on("error", reject);
				});

				const payload = {
					body: msg,
					attachment: fs.createReadStream(videoPath)
				};

				const callback = () => { if (fs.existsSync(videoPath)) fs.unlinkSync(videoPath); };
				return message && typeof message.reply === "function" 
					? message.reply(payload, callback) 
					: api.sendMessage(payload, event.threadID, callback, event.messageID);

			} catch (err) {
				console.error("Help video attachment failed, sending text only:", err);
				if (fs.existsSync(videoPath)) fs.unlinkSync(videoPath);
				return sendMsg(msg);
			}
		} else {
			return sendMsg(msg);
		}
	}
};

View raw file