client.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Client, ClientUser, Intents, Util } from "discord.js";
  2. import { XenforoClient } from "./xenforo";
  3. export const FORUMS_DOMAIN = "https://custommaid3d2.com";
  4. export class BotClient {
  5. public bot = new Client({
  6. intents: [
  7. Intents.FLAGS.GUILDS,
  8. Intents.FLAGS.GUILD_MEMBERS,
  9. Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
  10. Intents.FLAGS.GUILD_MESSAGES,
  11. Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
  12. Intents.FLAGS.DIRECT_MESSAGES,
  13. Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
  14. ]
  15. });
  16. public forum = new XenforoClient(`${FORUMS_DOMAIN}/api`, process.env.FORUM_API_KEY ?? "");
  17. get botUser(): ClientUser {
  18. if (!this.bot.user)
  19. throw new Error("No bot user detected!");
  20. return this.bot.user;
  21. }
  22. get usernameMention(): string {
  23. return `<@${this.botUser.id}>`;
  24. }
  25. get nameMention(): string {
  26. return `<@!${this.botUser.id}>`;
  27. }
  28. get cleanMention(): string {
  29. return Util.removeMentions(`@${client.botUser.username}`);
  30. }
  31. }
  32. export const client = new BotClient();