You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

import { BotEmitter, initCommands } from "@wackford/mod.ts";
import { Intents, sendMessage } from "@wackford/discordeno.ts";
import initLocalCommands from "./commands/index.ts";
import initOnMessage from "./events/onMessage.ts";
import initAIs from "./ai/index.ts";
import initDB from "./database.ts";
import config from "./config.ts";
export class GoofyAhhException extends Error {
constructor(message: string) {
super(message);
this.name = "GoofyAhhException";
}
}
await initDB();
initOnMessage();
initLocalCommands();
initCommands();
initAIs();
let hasSent = false
await BotEmitter.on("ready", (bot) => {
if (hasSent) return
Deno.addSignalListener("SIGINT", () => {
config.discord.channels.forEach(async channelId => {
await sendMessage(bot, channelId, {
content: "Apologies, bot going down for maintenance!"
})
})
})
config.discord.channels.forEach(async channelId => {
await sendMessage(bot, channelId, {
content: "The bot is back online!"
})
})
hasSent = true
})
await BotEmitter.emit("start", {
token: Deno.env.get("TOKEN") ?? config.discord.token ?? (() => {
throw new GoofyAhhException("No token?");
})(),
intents: Intents.Guilds | Intents.GuildMessages | Intents.MessageContent,
});