Use the active token if one exists
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user