From 5fdb37f7f89b94fde10400d33bdf0b934d2c1f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20L=27abb=C3=A9?= Date: Sun, 31 May 2026 12:37:57 +0000 Subject: [PATCH] Refactor token retrieval and error handling in main function; streamline environment variable checks for Discord token. --- bot.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index 743223d..2bce749 100755 --- a/bot.py +++ b/bot.py @@ -1,8 +1,8 @@ # main.py import discord from discord.ext import commands +import itertools import os -import sys from dotenv import load_dotenv from utils.sql_commands import initialize_database @@ -46,12 +46,10 @@ def main(): load_dotenv() initialize_database() client = Client() - token = os.getenv("TOKEN") - if token is not None: - threading.Thread(target=run_web, daemon=True).start() - client.run(token) - else: - print("Token is missing.") + token = os.getenv("DISCORD_TOKEN") or os.getenv("TOKEN") + if not token: + raise SystemExit("ERROR: Discord token not found. Set DISCORD_TOKEN or TOKEN in environment.") + client.run(token) if __name__ == "__main__":