2025-02-27 03:56:30 +00:00
|
|
|
import { config } from "#/config";
|
2025-03-02 23:55:01 +00:00
|
|
|
import { c } from "#/di";
|
|
|
|
|
import { InjectionToken } from "@needle-di/core";
|
2025-02-27 03:56:30 +00:00
|
|
|
|
|
|
|
|
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,
|
2025-03-01 21:10:31 +00:00
|
|
|
] 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,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-02-27 03:56:30 +00:00
|
|
|
|
2025-03-02 23:55:01 +00:00
|
|
|
export type BotType = ReturnType<typeof createBotWithToken>
|
|
|
|
|
export const Bot = new InjectionToken<BotType>("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)
|
|
|
|
|
},
|
2025-02-27 03:56:30 +00:00
|
|
|
})
|