Jonell01's picture
Update modules/commands/help.js
7c4f99b verified
module.exports.config = {
name: "help",
version: "1.0.0",
hasPermission: 0, // Fixed typo
credits: "august",
description: "Guide for new users",
commandCategory: "system",
usages: "/help",
hide: true,
usePrefix: true,
cooldowns: 5,
envConfig: {
autoUnsend: true,
delayUnsend: 60
}
};
const mathSansBold = {
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: "๐—“"
};
module.exports.handleEvent = function ({ api, event, getText }) {
const { commands } = global.client;
const { threadID, messageID, body } = event;
if (!body || typeof body == "undefined" || body.indexOf("commands") !== 0) return;
const splitBody = body.slice(body.indexOf("commands")).trim().split(/\s+/);
if (splitBody.length === 1 || !commands.get(splitBody[1].toLowerCase())) return;
const threadSetting = global.data.threadData.get(parseInt(threadID)) || {};
const command = commands.get(splitBody[1].toLowerCase());
const prefix = threadSetting.PREFIX || global.config.PREFIX;
return api.sendMessage(
getText("moduleInfo", command.config.name, command.config.description,
`${prefix}${command.config.name} ${(command.config.usages) ? command.config.usages : ""}`,
command.config.commandCategory, command.config.cooldowns,
command.config.hasPermission === 0 ? getText("user") :
command.config.hasPermission === 1 ? getText("adminGroup") : getText("adminBot"),
command.config.credits),
threadID, messageID
);
};
module.exports.run = async function ({ api, event, args }) {
const uid = event.senderID;
const userName = (await api.getUserInfo(uid))[uid].name;
const { commands } = global.client;
const { threadID, messageID } = event;
const threadSetting = global.data.threadData.get(parseInt(threadID)) || {};
const moduleConfig = global.configModule?.[this.config.name] || {}; // Fix for undefined configModule
const autoUnsend = moduleConfig.autoUnsend ?? false;
const delayUnsend = moduleConfig.delayUnsend ?? 60;
const prefix = threadSetting.PREFIX || global.config.PREFIX;
const categories = new Set();
const categorizedCommands = new Map();
for (const [name, value] of commands) {
if (value.config.hide) continue;
const categoryName = value.config.commandCategory;
if (!categories.has(categoryName)) {
categories.add(categoryName);
categorizedCommands.set(categoryName, []);
}
categorizedCommands.get(categoryName).push(`โ”‚ โœง ${value.config.name}`);
}
let msg = `๐–ง๐–พ๐—’ ${userName}, ๐—๐—๐–พ๐—Œ๐–พ ๐–บ๐—‹๐–พ ๐–ผ๐—ˆ๐—†๐—†๐–บ๐—‡๐–ฝ๐—Œ ๐—๐—๐–บ๐— ๐—†๐–บ๐—’ ๐—๐–พ๐—…๐—‰ ๐—’๐—ˆ๐—Ž:\n\n`;
for (const categoryName of categories) {
const categoryNameSansBold = categoryName.split("").map(c => mathSansBold[c] || c).join("");
msg += `โ•ญโ”€โใ€Œ ${categoryNameSansBold} ใ€\n`;
msg += categorizedCommands.get(categoryName).join("\n");
msg += "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โŸก\n";
}
msg += `โ”œโ”€โ”€โ”€โ”€โ”€โ˜พโ‹†\nโ”‚ ยป Total commands: [ ${commands.size} ]\nโ”‚ใ€Œ โ˜พโ‹† PREFIX: ${prefix} ใ€\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โŸก`;
return api.sendMessage(msg, threadID, async (error, info) => {
if (autoUnsend) {
await new Promise(resolve => setTimeout(resolve, delayUnsend * 60000));
return api.unsendMessage(info.messageID);
}
});
};