From 30c91863851c7aa3ee32f54e262d77b00f54acde Mon Sep 17 00:00:00 2001 From: timofey Date: Wed, 30 Aug 2023 20:58:47 +0000 Subject: [PATCH] better `DISCORD_TOKEN` error --- starbot/starbot/__main__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/starbot/starbot/__main__.py b/starbot/starbot/__main__.py index d8840e7..4724d19 100644 --- a/starbot/starbot/__main__.py +++ b/starbot/starbot/__main__.py @@ -13,7 +13,15 @@ from .db import AbstractDbFactory async def _main(): token = os.getenv("DISCORD_TOKEN") - assert token is not None + if token is None: + print( + """\ +DISCORD_TOKEN environment variable is not set +edit .secrets/starbot.env with the following content (substitute with the token): +DISCORD_TOKEN = \ +""" + ) + exit(1) dbfm = os.getenv("DBF_MODULE") assert dbfm is not None DBF: AbstractDbFactory = importlib.import_module(dbfm).DBF