import { config } from "#/config"; import { c } from "#/di"; import { InjectionToken } from "@needle-di/core"; import {createBot, Intents} from "discordeno" const intents = [ Intents.GuildModeration , Intents.GuildWebhooks , Intents.GuildExpressions , Intents.GuildScheduledEvents , Intents.GuildMessagePolls , Intents.GuildIntegrations , Intents.GuildInvites , Intents.GuildMessageReactions , Intents.GuildPresences , Intents.DirectMessages , Intents.DirectMessageReactions , Intents.GuildMembers , Intents.Guilds , Intents.GuildInvites , Intents.GuildMessages, ] as const export const createBotWithToken = (token: string) => createBot({ intents: intents.reduce((acc, curr) => acc | curr, Intents.Guilds), token: token, desiredProperties: { interaction: { id: true, data: true, type: true, token: true, message: true, channelId: true, channel: true, guildId: true, guild: true, user: true, member: true, }, message: { id: true, member: true, guildId: true, }, } }) export type BotType = ReturnType export const Bot = new InjectionToken("DISCORD_BOT") c.bind({ provide: Bot, async: true, useFactory: async () => { let token = config.DISCORD_TOKEN if(!token) { throw new Error('no discord token found. bot cant start'); } return createBotWithToken(token) }, })