project setup
This commit is contained in:
30
src/bot.ts
Executable file
30
src/bot.ts
Executable file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user