i get the token like this
token_url = "https://id.twitch.tv/oauth2/token"
data = {
"grant_type": "refresh_token",
"client_id": os.environ["CLIENT_ID"],
"client_secret": client_secret,
"refresh_token":refreshtoken
}
response = requests.post(token_url, data=data)
new_access_token = response.json()["access_token"]
expires= response.json()["expires_in"]
I am running the bot like this:
bot = commands.Bot(
token=new_access_token,
client_id=os.environ['CLIENT_ID'],
nick = "testtwitchmodaicool",
prefix="!",
initial_channels=["aimodtest"]
)
if __name__ =='__main__':
bot.run()
I then have a loop:
while True:
time.sleep(expires)
*over here get another token from refresh
******** Now over here how do I replace the token of the bot and rerun it