Prompt the user before deleting their config for wrong credentials

No more backfires.
This commit is contained in:
Twentysix 2016-06-14 00:55:51 +02:00
parent c9e948ae26
commit 8fa80da958

16
red.py
View File

@ -388,12 +388,16 @@ if __name__ == '__main__':
loop.run_until_complete(main()) loop.run_until_complete(main())
except discord.LoginFailure: except discord.LoginFailure:
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
print("Invalid login credentials. Restart Red and configure it" choice = input("Invalid login credentials. "
" properly.") "If they worked before Discord might be having temporary "
shutil.copy('data/red/settings.json', "technical issues.\nIn this case, press enter and "
'data/red/settings-{}.bak'.format(int(time.time()))) "try again later.\nOtherwise you can type 'reset' to "
# Hopefully this won't backfire in case of discord servers' problems "delete the current configuration and redo the setup process "
os.remove('data/red/settings.json') "again the next start.\n> ")
if choice.strip() == "reset":
shutil.copy('data/red/settings.json',
'data/red/settings-{}.bak'.format(int(time.time())))
os.remove('data/red/settings.json')
except: except:
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
loop.run_until_complete(bot.logout()) loop.run_until_complete(bot.logout())