← back to browse
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");

module.exports = {
  config: {
    name: "help",
    aliases: ["menu", "commands"],
    version: "1.0.0",
    author: "Mohammad Maruf",

    shortDescription: "Show all commands",
    longDescription: "Show all available commands in a clean menu.",

    category: "chat",

    guide: {
      en: "{pn}help [command name]"
    }
  },

  onStart: async function ({ message, args, prefix }) {
    const allCommands = global.GoatBot.commands;

    const fancyFont = (str) => {
      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 [...String(str)]
        .map(char => map[char] || char)
        .join("");
    };

    const categoryFont = (str) => {
      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 [...String(str)]
        .map(char => map[char] || char)
        .join("");
    };

    const cleanCategoryName = (text) => {
      if (!text) return "others";

      return String(text)
        .trim()
        .toLowerCase();
    };

    if (args[0]) {
      const cmdName = String(args[0]).toLowerCase();

      const cmd =
        allCommands.get(cmdName) ||
        [...allCommands.values()].find(command =>
          Array.isArray(command.config?.aliases) &&
          command.config.aliases.some(
            alias =>
              String(alias).toLowerCase() === cmdName
          )
        );

      if (!cmd) {
        return message.reply(
          `โŒ ${fancyFont("Command")} "${cmdName}" ${fancyFont("not found!")}`
        );
      }

      const config = cmd.config || {};

      const description =
        typeof config.longDescription === "object"
          ? config.longDescription.en ||
            config.shortDescription ||
            "No description"
          : config.longDescription ||
            config.shortDescription ||
            "No description";

      let guide =
        config.guide ||
        `${prefix}${config.name}`;

      if (typeof guide === "object") {
        guide =
          guide.en ||
          `${prefix}${config.name}`;
      }

      guide = String(guide).replace(
        /\{pn\}/g,
        `${prefix}${config.name}`
      );

      const infoMsg =
`โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  โœฆ ${categoryFont("COMMAND INFO")} โœฆ
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("NAME")} ใ€
โ”‚  โŸถ ${fancyFont(config.name || "Unknown")}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("CATEGORY")} ใ€
โ”‚  โŸถ ${categoryFont(
        (config.category || "Others").toUpperCase()
      )}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("VERSION")} ใ€
โ”‚  โŸถ ${fancyFont(config.version || "1.0.0")}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("AUTHOR")} ใ€
โ”‚  โŸถ ${fancyFont(config.author || "Unknown")}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("DESCRIPTION")} ใ€
โ”‚  โŸถ ${description}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${fancyFont("USAGE")} ใ€
โ”‚  โŸถ ${guide}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ`;

      return message.reply(infoMsg);
    }

    const categories = {};

    for (const [name, command] of allCommands) {
      if (!command || !command.config) {
        continue;
      }

      const category = cleanCategoryName(
        command.config.category
      );

      if (!categories[category]) {
        categories[category] = [];
      }

      if (!categories[category].includes(name)) {
        categories[category].push(name);
      }
    }

    const formatCommands = (commands) => {
      return commands
        .sort((a, b) =>
          String(a).localeCompare(String(b))
        )
        .map((name, index) => {
          const number = String(index + 1).padStart(2, "0");

          return `โ”‚  ${number} โŸถ ${fancyFont(name)}`;
        })
        .join("\n");
    };

    const categoryOrder = [
      "18+",
      "admin",
      "ai",
      "ai-image",
      "anime",
      "birthday",
      "box",
      "box chat",
      "config",
      "contacts",
      "custom",
      "economy",
      "events",
      "fun",
      "game",
      "group",
      "image",
      "info",
      "information",
      "love",
      "media",
      "music",
      "other",
      "owner",
      "rank",
      "software",
      "supportgc",
      "system",
      "tools",
      "utility",
      "wiki"
    ];

    const sortedCategories =
      Object.keys(categories).sort((a, b) => {
        const indexA = categoryOrder.indexOf(a);
        const indexB = categoryOrder.indexOf(b);

        if (indexA === -1 && indexB === -1) {
          return a.localeCompare(b);
        }

        if (indexA === -1) {
          return 1;
        }

        if (indexB === -1) {
          return -1;
        }

        return indexA - indexB;
      });

    let msg =
`โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚     โœฆ ${fancyFont("HELP")} โœฆ
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€ใ€Œ ${categoryFont("PREFIX")} ใ€
โ”‚  โŸก โŸถ ${prefix}
โ”‚  โŸก ${categoryFont("TOTAL")} โŸถ ${allCommands.size}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

`;

    for (const category of sortedCategories) {
      const title = categoryFont(
        category.toUpperCase()
      );

      msg +=
`โ•ญโ”€ใ€Œ ${title} ใ€
${formatCommands(categories[category])}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

`;
    }

    msg +=
`โ•ญโ”€ใ€Œ ${categoryFont("HOW TO USE")} ใ€
โ”‚  โŸก โŸถ ${prefix}<command>
โ”‚
โ”‚  โœฆ ${fancyFont("Example")}
โ”‚  โŸถ ${prefix}owner
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

       โ™ก ${fancyFont("Mohammad Maruf")} โ™ก`;

    return message.reply(msg);
  }
};

View raw file