import { isAuthorisedAsync } from "../util"; import { plgMgr, COMMAND_PREFIX } from "src/main"; import { Command, ICommandData, Plugin } from "src/model/plugin"; import { client } from "src/client"; @Plugin export class Help { @Command({ type: "mention", pattern: "help" }) async showHelp({ message }: ICommandData): Promise { const isAuthed = await isAuthorisedAsync(message.member); let baseCommands = "\n"; let modCommands = "\n"; let prefixCommands = "\n"; for (const doc of plgMgr.documentation) { if (isAuthed && doc.auth) { if (doc.type == "prefix") prefixCommands = `${prefixCommands}${COMMAND_PREFIX}${doc.example} - ${doc.doc}\n`; else if (doc.type == "mention") modCommands = `${modCommands}${doc.example} - ${doc.doc}\n`; } else if (!doc.auth) baseCommands = `${baseCommands}${doc.example} - ${doc.doc}\n`; } let msg = `Hello! I am ${client.botUser.username}! My job is to help with C(O)M-related problems!\nPing me with one of the following commands:\n\`\`\`${baseCommands}\`\`\``; if (isAuthed) msg = `${msg}\nšŸ‘‘**Moderator commands**šŸ‘‘\n\`\`\`${modCommands}\`\`\`\n**Prefix commands**\`\`\`${prefixCommands}\`\`\``; message.reply(msg); } }