Use the active token if one exists

This commit is contained in:
Logan Cusano
2025-06-29 18:00:21 -04:00
parent 0300ef2407
commit 743e405ff6

View File

@@ -77,14 +77,16 @@ async def join_server(websocket, system_id, guild_id, channel_id):
print("Bot status:", bot_status) print("Bot status:", bot_status)
# Check if the bot is running # Check if the bot is running
if 'bot_running' not in bot_status or not bot_status['bot_running']: if 'bot_running' not in bot_status or not bot_status['bot_running']:
# Get a token # Get a token if one is not already
global bot_token if not bot_token:
bot_token = await srv_api.request_token() global bot_token
print("Bot token:", bot_token) bot_token = await srv_api.request_token()
if not bot_token or "token" not in bot_token or not bot_token['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 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 # 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 # 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']: if 'connected_guilds' not in bot_status or int(guild_id) not in bot_status['connected_guilds']:
# Join the server # Join the server