31 lines
667 B
TypeScript
Executable File
31 lines
667 B
TypeScript
Executable File
import { createBot, Intents, startBot } from "npm:discordeno@18.0.1";
|
|
import * as dotenv from "jsr:@std/dotenv";
|
|
import { messagehandler } from "./messages.ts";
|
|
|
|
const env = dotenv.loadSync();
|
|
|
|
if (typeof env.BOT_TOKEN !== "string") {
|
|
throw new Error("Bot token is required in .env file");
|
|
}
|
|
|
|
const bot = createBot({
|
|
token: env.BOT_TOKEN,
|
|
intents: Intents.Guilds | Intents.GuildMessages | Intents.MessageContent |
|
|
Intents.DirectMessages,
|
|
events: {
|
|
ready() {
|
|
console.log("Bot is ready!");
|
|
},
|
|
async messageCreate(bot, message) {
|
|
await messagehandler(bot, message);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Setup desired properties
|
|
|
|
|
|
|
|
await startBot(bot);
|
|
|