So I have commands.bot function with the token and everything else and I want to update the token every time the user logs in. I get the token using socket.on but I'm not sure how to update the bot so all the bots events can be used in his twitch account. Any help would be appreciated thanks.
@socketio.on("bottoken")
def gettoken(data):
global thetoken
global bot
thetoken = json.loads(data)
thetoken = str(thetoken)
os.environ["TMI_TOKEN"]=thetoken
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(my_async_function())