add discord bot

This commit is contained in:
Corban-Lee Jones 2025-04-22 12:19:22 +01:00
parent c8670bfe65
commit 86134ed2e1
3 changed files with 23 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import path from "path";
import express from "express";
import engine from "ejs-mate";
import "@bot/bot";
import homeRouter from "@server/routers/home.router";
const app = express();

20
src/bot/bot.ts Normal file
View File

@ -0,0 +1,20 @@
import { Client, GatewayIntentBits, ActivityType } from "discord.js";
export const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildWebhooks
]
})
client.on("ready", () => {
if (!client.user) {
throw Error("Client is null");
}
client.user.setActivity("new sources", {type: ActivityType.Watching});
console.log(`Discord Bot ${client.user.displayName} is online!`)
});
client.login(process.env.BOT_TOKEN);

View File

@ -10,7 +10,8 @@
"DOM"
],
"paths": {
"@server/*": ["./src/server/*"]
"@server/*": ["./src/server/*"],
"@bot/*": ["./src/bot/*"]
},
"plugins": [
{"transform": "@zerollup/ts-transform-paths"}