diff --git a/scripts/cmds/help.js b/scripts/cmds/help.js index 3127838..75887f1 100644 --- a/scripts/cmds/help.js +++ b/scripts/cmds/help.js @@ -3,399 +3,129 @@ const axios = require("axios"); const path = require("path"); const { getPrefix } = global.utils; const { commands, aliases } = global.GoatBot; -const doNotDelete = "[ Remplace par le nom de ton bot ]"; +const doNotDelete = "๐ˆ๐“๐€๐‚๐‡๐ˆโคโ€๐Ÿ”ฅ๐ƒ๐„๐—๐“๐„๐”๐‘\n"; + +function formatFont(text) { + const fontMapping = { + 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: "๐™", + 1: "๐Ÿ", 2: "๐Ÿ", 3: "๐Ÿ‘", 4: "๐Ÿ’", 5: "๐Ÿ“", 6: "๐Ÿ”", 7: "๐Ÿ•", 8: "๐Ÿ–", 9: "๐Ÿ—", 0: "๐ŸŽ" + }; + return text.split('').map(char => fontMapping[char.toUpperCase()] || char).join(''); +} + +function formatFonts(text) { + const fontList = { + 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: "๐šฃ", + 1: "๐Ÿท", 2: "๐Ÿธ", 3: "๐Ÿน", 4: "๐Ÿบ", 5: "๐Ÿป", 6: "๐Ÿผ", 7: "๐Ÿฝ", 8: "๐Ÿพ", 9: "๐Ÿฟ", 0: "๐Ÿถ" + }; + return text.split('').map(char => fontList[char.toLowerCase()] || char).join(''); +} module.exports = { - config: { - name: "help", - version: "2.0", - author: "NTKhang - MarianCross", - countDown: 5, - role: 0, - description: { - en: "Voir l'utilisation des commandes" - }, - category: "info", - guide: { - en: "{pn} [vide | ]" - + "\n {pn} setmedia: dรฉfinir un mรฉdia pour help (rรฉpondre ร  une image/gif/vidรฉo)" - + "\n {pn} [-u | usage | -g | guide]: afficher uniquement le guide d'utilisation" - + "\n {pn} [-i | info]: afficher uniquement les informations de la commande" - + "\n {pn} [-r | role]: afficher uniquement les permissions de la commande" - + "\n {pn} [-a | alias]: afficher uniquement les alias de la commande" - }, - priority: 1 - }, - - langs: { - en: { - helpList: "โ•ญโ”€ Remplace par le nom de ton bot โ”€โ•ฎ\n%1\nโ•ฐโ”€ Total: %2 commandes โ”€โ•ฏ\nUtilisez %3help pour les dรฉtails de la commande", - commandNotFound: "La commande \"%1\" n'existe pas", - getInfoCommand: "โ•ญโ”€ INFOS COMMANDE โ”€โ•ฎ" - + "\nโ”‚ Nom: %1" - + "\nโ”‚ Description: %2" - + "\nโ”‚ Alias: %3" - + "\nโ”‚ Alias du groupe: %4" - + "\nโ”‚ Version: %5" - + "\nโ”‚ Rรดle: %6" - + "\nโ”‚ Cooldown: %7s" - + "\nโ”‚ Auteur: %8" - + "\nโ”œโ”€ UTILISATION โ”€โ”ค" - + "\nโ”‚%9" - + "\nโ”œโ”€ NOTES โ”€โ”ค" - + "\nโ”‚ peut รชtre modifiรฉ" - + "\nโ”‚ [a|b|c] est a ou b ou c" - + "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ", - onlyInfo: "โ•ญโ”€ INFOS โ”€โ•ฎ" - + "\nโ”‚ Nom: %1" - + "\nโ”‚ Description: %2" - + "\nโ”‚ Alias: %3" - + "\nโ”‚ Alias du groupe: %4" - + "\nโ”‚ Version: %5" - + "\nโ”‚ Rรดle: %6" - + "\nโ”‚ Cooldown: %7s" - + "\nโ”‚ Auteur: %8" - + "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ", - onlyUsage: "โ•ญโ”€ UTILISATION โ”€โ•ฎ" - + "\nโ”‚%1" - + "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ", - onlyAlias: "โ•ญโ”€ ALIAS โ”€โ•ฎ" - + "\nโ”‚ Alias: %1" - + "\nโ”‚ Alias du groupe: %2" - + "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ", - onlyRole: "โ•ญโ”€ Rร”LE โ”€โ•ฎ" - + "\nโ”‚%1" - + "\nโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ", - doNotHave: "Aucun", - roleText0: "0 (Tous les utilisateurs)", - roleText1: "1 (Administrateurs du groupe)", - roleText2: "2 (Administrateurs du bot)", - roleText0setRole: "0 (dรฉfini, tous les utilisateurs)", - roleText1setRole: "1 (dรฉfini, administrateurs du groupe)" - } - }, - - onStart: async function ({ message, args, event, threadsData, getLang, role, globalData }) { - // โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” SET MEDIA ATTACHMENT โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” // - if (args[0]?.toLowerCase() === "setmedia") { - if (event.messageReply?.attachments?.length > 0) { - const attachment = event.messageReply.attachments[0]; - if (attachment.type === "photo" || attachment.type === "video" || attachment.type === "animated_image") { - try { - const helpMediaPath = path.normalize(`${process.cwd()}/assets/help_media.${attachment.type === "photo" ? "jpg" : attachment.type === "video" ? "mp4" : "gif"}`); - - // Crรฉer le dossier assets s'il n'existe pas - const assetsDir = path.dirname(helpMediaPath); - if (!fs.existsSync(assetsDir)) { - fs.mkdirSync(assetsDir, { recursive: true }); - } - - // Tรฉlรฉcharger et sauvegarder le media - const response = await axios.get(attachment.url, { responseType: 'arraybuffer' }); - fs.writeFileSync(helpMediaPath, Buffer.from(response.data)); - - return message.reply("โœ… Media pour la commande help dรฉfini avec succรจs !"); - } catch (error) { - return message.reply("โŒ Erreur lors de la sauvegarde du media : " + error.message); - } - } else { - return message.reply("โŒ Veuillez rรฉpondre ร  une image, GIF ou vidรฉo valide."); - } - } else { - return message.reply("โŒ Veuillez rรฉpondre ร  un message contenant une image, GIF ou vidรฉo."); - } - } - const langCode = await threadsData.get(event.threadID, "data.lang") || global.GoatBot.config.language; - let customLang = {}; - const pathCustomLang = path.normalize(`${process.cwd()}/languages/cmds/${langCode}.js`); - if (fs.existsSync(pathCustomLang)) - customLang = require(pathCustomLang); - - const { threadID } = event; - const threadData = await threadsData.get(threadID); - const prefix = getPrefix(threadID); - const commandName = (args[0] || "").toLowerCase(); - let command = commands.get(commandName) || commands.get(aliases.get(commandName)); - - // Check for aliases - const aliasesData = threadData.data.aliases || {}; - if (!command) { - for (const cmdName in aliasesData) { - if (aliasesData[cmdName].includes(commandName)) { - command = commands.get(cmdName); - break; - } - } - } - - if (!command) { - const globalAliasesData = await globalData.get('setalias', 'data', []); - for (const item of globalAliasesData) { - if (item.aliases.includes(commandName)) { - command = commands.get(item.commandName); - break; - } - } - } - - // โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” LIST ALL COMMAND โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” // - if (!command && !args[0]) { - // Mapping des catรฉgories existantes vers les nouvelles catรฉgories - const categoryMapping = { - // Vos catรฉgories existantes -> nouvelles catรฉgories - "ai": "ai", - "image": "ai", - "generate": "ai", - "bot": "ai", - "group": "admin", - "admin": "admin", - "moderation": "admin", - "game": "entertainment", - "fun": "entertainment", - "entertainment": "entertainment", - "music": "media", - "download": "media", - "media": "media", - "video": "media", - "utility": "utility", - "tool": "utility", - "tools": "utility", - "search": "utility", - "rank": "system", - "level": "system", - "economy": "system", - "info": "system", - "system": "system" - }; - - // Configuration des catรฉgories finales - const categoryConfig = { - "ai": { title: "๐—œ๐—”" }, - "admin": { title: "๐—”๐——๐— ๐—œ๐—ก๐—œ๐—ฆ๐—ง๐—ฅ๐—”๐—ง๐—œ๐—ข๐—ก" }, - "entertainment": { title: "๐——๐—œ๐—ฉ๐—˜๐—ฅ๐—ง๐—œ๐—ฆ๐—ฆ๐—˜๐— ๐—˜๐—ก๐—ง" }, - "utility": { title: "๐—จ๐—ง๐—œ๐—Ÿ๐—œ๐—ง๐—”๐—œ๐—ฅ๐—˜๐—ฆ" }, - "media": { title: "๐— ๐—˜๐——๐—œ๐—”" }, - "system": { title: "๐—ฆ๐—ฌ๐—ฆ๐—ง๐—˜๐— ๐—˜" } - }; - - const categorizedCommands = {}; - let totalCommands = 0; - - // Organiser les commandes par catรฉgorie - for (const [name, cmdData] of commands) { - if (cmdData.config.role > 1 && role < cmdData.config.role) - continue; - - totalCommands++; - const originalCategory = cmdData.config.category?.toLowerCase() || "utility"; - const mappedCategory = categoryMapping[originalCategory] || "utility"; - - if (!categorizedCommands[mappedCategory]) { - categorizedCommands[mappedCategory] = []; - } - categorizedCommands[mappedCategory].push(name); - } - - let helpMessage = ""; - - // Construire le message par catรฉgories - const orderedCategories = ["ai", "admin", "entertainment", "utility", "media", "system"]; - - for (const category of orderedCategories) { - if (categorizedCommands[category] && categorizedCommands[category].length > 0) { - const config = categoryConfig[category]; - - helpMessage += `\nโ”โ”โ” ${config.title} โ”โ”โ”\n`; - - // Grouper les commandes par ligne (max 6 par ligne) - const commands = categorizedCommands[category].sort(); - const chunked = []; - for (let i = 0; i < commands.length; i += 6) { - chunked.push(commands.slice(i, i + 6)); - } - - for (const chunk of chunked) { - helpMessage += chunk.join(", ") + "\n"; - } - } - } - - // Ajouter les commandes des autres catรฉgories non mappรฉes - for (const [category, cmdList] of Object.entries(categorizedCommands)) { - if (!orderedCategories.includes(category) && cmdList.length > 0) { - helpMessage += `\nโ”โ”โ” ${category.toUpperCase()} โ”โ”โ”\n`; - const commands = cmdList.sort(); - const chunked = []; - for (let i = 0; i < commands.length; i += 6) { - chunked.push(commands.slice(i, i + 6)); - } - - for (const chunk of chunked) { - helpMessage += chunk.join(", ") + "\n"; - } - } - } - - // Ajouter la section support - helpMessage += `\nโ”โ”โ” ๐—ฆ๐—จ๐—ฃ๐—ฃ๐—ข๐—ฅ๐—ง โ”โ”โ”\n`; - helpMessage += `Rejoignez la boรฎte d'assistance\n`; - helpMessage += `${prefix}callad pour contacter les administrateurs\n`; - - const finalMessage = getLang("helpList", helpMessage, totalCommands, prefix); - - // Prรฉparer l'objet de rรฉponse - const formSendMessage = { body: finalMessage }; - - // Ajouter un GIF/image si disponible - const mediaExtensions = ['.gif', '.jpg', '.jpeg', '.png', '.mp4']; - let helpMediaPath = null; - - for (const ext of mediaExtensions) { - const testPath = path.normalize(`${process.cwd()}/assets/help_media${ext}`); - if (fs.existsSync(testPath)) { - helpMediaPath = testPath; - break; - } - } - - if (helpMediaPath) { - formSendMessage.attachment = fs.createReadStream(helpMediaPath); - } - - return message.reply(formSendMessage); - } - // โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” COMMAND DOES NOT EXIST โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” // - else if (!command && args[0]) { - return message.reply(getLang("commandNotFound", args[0])); - } - // โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” INFO COMMAND โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” // - else { - const formSendMessage = {}; - const configCommand = command.config; - - let guide = configCommand.guide?.[langCode] || configCommand.guide?.["en"]; - if (guide == undefined) - guide = customLang[configCommand.name]?.guide?.[langCode] || customLang[configCommand.name]?.guide?.["en"]; - - guide = guide || { body: "" }; - if (typeof guide == "string") - guide = { body: guide }; - const guideBody = guide.body - .replace(/\{prefix\}|\{p\}/g, prefix) - .replace(/\{name\}|\{n\}/g, configCommand.name) - .replace(/\{pn\}/g, prefix + configCommand.name); - - const aliasesString = configCommand.aliases ? configCommand.aliases.join(", ") : getLang("doNotHave"); - const aliasesThisGroup = threadData.data.aliases ? (threadData.data.aliases[configCommand.name] || []).join(", ") : getLang("doNotHave"); - - let roleOfCommand = configCommand.role; - let roleIsSet = false; - if (threadData.data.setRole?.[configCommand.name]) { - roleOfCommand = threadData.data.setRole[configCommand.name]; - roleIsSet = true; - } - - const roleText = roleOfCommand == 0 ? - (roleIsSet ? getLang("roleText0setRole") : getLang("roleText0")) : - roleOfCommand == 1 ? - (roleIsSet ? getLang("roleText1setRole") : getLang("roleText1")) : - getLang("roleText2"); - - const author = configCommand.author; - const descriptionCustomLang = customLang[configCommand.name]?.description; - let description = checkLangObject(configCommand.description, langCode); - if (description == undefined) - if (descriptionCustomLang != undefined) - description = checkLangObject(descriptionCustomLang, langCode); - else - description = getLang("doNotHave"); - - let sendWithAttachment = false; - - if (args[1]?.match(/^-g|guide|-u|usage$/)) { - formSendMessage.body = getLang("onlyUsage", guideBody.split("\n").join("\nโ”‚")); - sendWithAttachment = true; - } - else if (args[1]?.match(/^-a|alias|aliase|aliases$/)) - formSendMessage.body = getLang("onlyAlias", aliasesString, aliasesThisGroup); - else if (args[1]?.match(/^-r|role$/)) - formSendMessage.body = getLang("onlyRole", roleText); - else if (args[1]?.match(/^-i|info$/)) - formSendMessage.body = getLang( - "onlyInfo", - configCommand.name, - description, - aliasesString, - aliasesThisGroup, - configCommand.version, - roleText, - configCommand.countDown || 1, - author || "" - ); - else { - formSendMessage.body = getLang( - "getInfoCommand", - configCommand.name, - description, - aliasesString, - aliasesThisGroup, - configCommand.version, - roleText, - configCommand.countDown || 1, - author || "", - guideBody.split("\n").join("\nโ”‚") - ); - sendWithAttachment = true; - } - - if (sendWithAttachment && guide.attachment) { - if (typeof guide.attachment == "object" && !Array.isArray(guide.attachment)) { - const promises = []; - formSendMessage.attachment = []; - - for (const keyPathFile in guide.attachment) { - const pathFile = path.normalize(keyPathFile); - - if (!fs.existsSync(pathFile)) { - const cutDirPath = path.dirname(pathFile).split(path.sep); - for (let i = 0; i < cutDirPath.length; i++) { - const pathCheck = `${cutDirPath.slice(0, i + 1).join(path.sep)}${path.sep}`; - if (!fs.existsSync(pathCheck)) - fs.mkdirSync(pathCheck); - } - const getFilePromise = axios.get(guide.attachment[keyPathFile], { responseType: 'arraybuffer' }) - .then(response => { - fs.writeFileSync(pathFile, Buffer.from(response.data)); - }); - - promises.push({ - pathFile, - getFilePromise - }); - } - else { - promises.push({ - pathFile, - getFilePromise: Promise.resolve() - }); - } - } + config: { + name: "help", + version: "1.20", + author: "Raphael Scholar ร— Gerald Max", + countDown: 9, + role: 0, + shortDescription: { + en: "View command usage and list" + }, + longDescription: { + en: "View detailed command usage and list all available commands" + }, + category: "info", + guide: { + en: "{pn} [command_name]" + }, + priority: 1 + }, + + onStart: async function ({ message, args, event, threadsData, role }) { + const { threadID } = event; + const prefix = await getPrefix(threadID); + + if (args.length === 0) { + const categories = {}; + let msg = ``; + + for (const [name, value] of commands) { + if (value.config.role > role) continue; + const category = value.config.category || "NO CATEGORY"; + if (!categories[category]) { + categories[category] = { commands: [] }; + } + categories[category].commands.push(name); + } - await Promise.all(promises.map(item => item.getFilePromise)); - for (const item of promises) - formSendMessage.attachment.push(fs.createReadStream(item.pathFile)); - } - } + Object.keys(categories).sort().forEach(category => { + const formattedCategory = formatFont(category.toUpperCase()); + msg += `\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\nโ”‚๐ŸŒฑ ๐Ÿฉธโ˜ž ${formattedCategory} โ˜œ๐Ÿฉธ ๐ŸŒฑ\n`; - return message.reply(formSendMessage); - } + const names = categories[category].commands.sort(); + for (let i = 0; i < names.length; i++) { + const formattedCmd = formatFonts(names[i]); + msg += `โ”‚๐Ÿ‘จ๐Ÿพโ€๐ŸŽจ| ${formattedCmd}\n`; } + + msg += `โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n`; + }); + + const totalCommands = commands.size; + msg += `๐ŸŒฑ ๐Ÿฉธโ˜ž ๐Ÿ‘จ๐Ÿพโ€๐ŸŽจ | ๐„๐๐‰๐Ž๐˜ โ˜œ๐Ÿฉธ ๐ŸŒฑ\n`; + msg += `โ”‚ยป ๐™ฒ๐šž๐š›๐š›๐šŽ๐š—๐š๐š•๐šข ๐š๐š‘๐š’๐šœ ๐š‹๐š˜๐š ๐š‘๐šŠ๐šœ \nโ”‚ใ€Ž ${totalCommands} ใ€๐šŒ๐š˜๐š–๐š–๐šŠ๐š—๐š๐šœ ๐š๐š‘๐šŠ๐š ๐šŒ-\nโ”‚-๐šŠ๐š— ๐š‹๐šŽ ๐šž๐šœ๐šŽ๐š\n`; + msg += `โ”‚ยป ๐šƒ๐šข๐š™๐šŽ ( ${prefix}help ๐˜ค๐˜ฎ๐˜ฅ_๐˜ฏ๐˜ข๐˜ฎ๐˜ฆ )\nโ”‚๐šƒ๐š˜ ๐šŸ๐š’๐šŽ๐š  ๐š๐šŽ๐š๐šŠ๐š’๐š•๐šœ\nโ”‚๐š˜๐š ๐š‘๐š˜๐š  ๐š๐š˜ ๐šž๐šœ๐šŽ\n`; + msg += `โ”‚ยป ๐šƒ๐šข๐š™๐šŽ ( ${prefix}๐šœ๐šž๐š™๐š™๐š˜๐š›๐š๐š๐šŒ ๐š๐š˜\nโ”‚๐š๐š˜ ๐š๐šŽ๐š ๐šŠ๐š๐š๐šŽ๐š ๐š๐š˜ ๐š–๐šข\nโ”‚๐š๐šŽ๐šŸ๐šœ ๐™ถ๐š›๐š˜๐šž๐š™ ๐šŒ๐š‘๐šŠ๐š )\n`; + msg += `โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n`; + msg += `โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n`; + msg += `โ”‚ ${doNotDelete}`; + msg += `โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`; + + await message.reply({ body: msg }); + } else { + const commandName = args[0].toLowerCase(); + const command = commands.get(commandName) || commands.get(aliases.get(commandName)); + + if (!command) { + await message.reply(`Command "${commandName || "undefined"}" not found.`); + } else { + const configCommand = command.config; + const roleText = roleTextToString(configCommand.role); + const author = configCommand.author || "Unknown"; + + const longDescription = configCommand.longDescription?.en || "No description"; + const guideBody = configCommand.guide?.en || "No guide available."; + const usage = guideBody.replace(/{p}/g, prefix).replace(/{n}/g, configCommand.name); + + const response = `๐ŸŒฑ ๐Ÿฉธโ˜ž NAME โ˜œ๐Ÿฉธ ๐ŸŒฑ +๐Ÿฅทโœจ ${configCommand.name} ๐Ÿฆ  โœฐโœฐ +๐ŸŒฑ ๐Ÿฉธโ˜ž INFO โ˜œ๐Ÿฉธ ๐ŸŒฑ +โ”‚ Description: ${longDescription} +โ”‚ Other names: ${configCommand.aliases ? configCommand.aliases.join(", ") : "None"} +โ”‚ Version: ${configCommand.version || "1.0"} +โ”‚ Role: ${roleText} +โ”‚ Cooldown: ${configCommand.countDown || 2}s +โ”‚ Author: ${author} +๐ŸŒฑ ๐Ÿฉธโ˜ž Usageโ˜œ๐Ÿฉธ ๐ŸŒฑ +๐Ÿ‘จ๐Ÿพโ€๐ŸŽจ ${usage} +๐ŸŒฑ ๐Ÿฉธโ˜ž Notesโ˜œ๐Ÿฉธ ๐ŸŒฑ +๐Ÿ‘จ๐Ÿพโ€๐ŸŽจ The content inside can be changed +๐Ÿ‘จ๐Ÿพโ€๐ŸŽจ The content inside [a|b|c] is a or b or c +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`; + + await message.reply(response); + } + } + } }; -function checkLangObject(data, langCode) { - if (typeof data == "string") - return data; - if (typeof data == "object" && !Array.isArray(data)) - return data[langCode] || data.en || undefined; - return undefined; - } +function roleTextToString(roleText) { + switch (roleText) { + case 0: return "0 (All users)"; + case 1: return "1 (Group administrators)"; + case 2: return "2 (Admin bot)"; + default: return "Unknown role"; + } + }