This commit is contained in:
2026-05-19 19:25:02 +02:00
commit 79c814bb64
10 changed files with 994 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import { Client, Events, GatewayIntentBits, TextChannel } from 'discord.js';
import { config } from './config';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on(Events.ThreadCreate, async (thread) => {
if (thread.parentId !== config.forumChannelId) return;
const channel = await client.channels.fetch(config.announceChannelId);
if (channel instanceof TextChannel) {
await channel.send(`Neues Event: **${thread.name}** — ${thread.url}`);
}
});
client.login(config.botToken);
+21
View File
@@ -0,0 +1,21 @@
import 'dotenv/config';
function readRequiredEnv(name: string): string {
const value = process.env[name]?.trim();
// Centralizing this check keeps the rest of the bot free from defensive
// env handling and makes startup fail immediately with a clear message.
if (!value) {
throw new Error(
`Missing required environment variable ${name}. Set it in the environment or in a .env file.`,
);
}
return value;
}
export const config = {
botToken: readRequiredEnv('DISCORD_BOT_TOKEN'),
forumChannelId: readRequiredEnv('DISCORD_FORUM_CHANNEL_ID'),
announceChannelId: readRequiredEnv('DISCORD_ANNOUNCE_CHANNEL_ID'),
};