From 743e405ff636b8dc2bbdd3ad10a875e827c45bdf Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 29 Jun 2025 18:00:21 -0400 Subject: [PATCH] Use the active token if one exists --- app/client.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/client.py b/app/client.py index 9b0347f..1034225 100644 --- a/app/client.py +++ b/app/client.py @@ -77,14 +77,16 @@ async def join_server(websocket, system_id, guild_id, channel_id): print("Bot status:", bot_status) # Check if the bot is running if 'bot_running' not in bot_status or not bot_status['bot_running']: - # Get a token - global bot_token - bot_token = await srv_api.request_token() - print("Bot token:", bot_token) - if not bot_token or "token" not in bot_token or not bot_token['token']: - raise Exception("No bot token received") # TODO - Handle this better + # Get a token if one is not already + if not bot_token: + global bot_token + bot_token = await srv_api.request_token() + if not bot_token or "token" not in bot_token or not bot_token['token']: + raise Exception("No bot token received") # TODO - Handle this better + bot_token = bot_token['token'] + print("Bot token:", bot_token) # Run the bot if not - await drb_api.start_bot(bot_token['token']) + await drb_api.start_bot(bot_token) # Check if the bot is connected to the guild, if not join if 'connected_guilds' not in bot_status or int(guild_id) not in bot_status['connected_guilds']: # Join the server