From 69f68d1b3cc92b8dc5021c8ffa563f28f2b0f236 Mon Sep 17 00:00:00 2001 From: KGFCH2 Date: Tue, 2 Jun 2026 14:06:38 +0530 Subject: [PATCH] fix: validate required bot environment variables at startup --- bot/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bot/index.js b/bot/index.js index 2fda380..5133e5d 100644 --- a/bot/index.js +++ b/bot/index.js @@ -2,6 +2,21 @@ require("dotenv").config(); +const requiredEnv = [ + "DISCORD_TOKEN", + "DISCORD_CLIENT_ID", + "API_URL", + "BOT_API_KEY", +]; +const missingEnv = requiredEnv.filter((name) => !process.env[name]); +if (missingEnv.length) { + console.error( + "❌ Missing required bot environment variables:", + missingEnv.join(", "), + ); + process.exit(1); +} + const fs = require("node:fs"); const path = require("node:path"); const { Client, Collection, GatewayIntentBits } = require("discord.js");