From 86134ed2e1dc516eb4f1ad6d3788438d9d24d42a Mon Sep 17 00:00:00 2001 From: Corban-Lee Date: Tue, 22 Apr 2025 12:19:22 +0100 Subject: [PATCH] add discord bot --- src/app.ts | 1 + src/bot/bot.ts | 20 ++++++++++++++++++++ tsconfig.json | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/bot/bot.ts diff --git a/src/app.ts b/src/app.ts index 330a719..ea704d5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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(); diff --git a/src/bot/bot.ts b/src/bot/bot.ts new file mode 100644 index 0000000..4b96e39 --- /dev/null +++ b/src/bot/bot.ts @@ -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); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 989c0e7..1018977 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,8 @@ "DOM" ], "paths": { - "@server/*": ["./src/server/*"] + "@server/*": ["./src/server/*"], + "@bot/*": ["./src/bot/*"] }, "plugins": [ {"transform": "@zerollup/ts-transform-paths"}