help.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { isAuthorisedAsync } from "../util";
  2. import { CommandSet, Command } from "src/model/command";
  3. import { Message } from "discord.js";
  4. import { getDocumentation } from "src/main";
  5. @CommandSet
  6. export class Help {
  7. @Command({ pattern: "help" })
  8. async showHelp(msg: Message) {
  9. let isAuthed = await isAuthorisedAsync(msg.member);
  10. let baseCommands = "\n";
  11. let modCommands = "\n";
  12. for (let doc of getDocumentation()) {
  13. if (isAuthed && doc.auth)
  14. modCommands = `${modCommands}${doc.example} - ${doc.doc}\n`;
  15. else if (!doc.auth)
  16. baseCommands = `${baseCommands}${doc.example} - ${doc.doc}\n`;
  17. }
  18. let name = process.env.FOOLS == "TRUE" ? "HorseBot" : "NoctBot";
  19. let message = `Hello! I am ${name}! My job is to help with C(O)M-related problems!\nPing me with one of the following commands:\n\`\`\`${baseCommands}\`\`\``;
  20. if (isAuthed)
  21. message = `${msg.author.toString()} ${message}\n👑**Moderator commands**👑\n\`\`\`${modCommands}\`\`\``;
  22. msg.channel.send(message);
  23. }
  24. }