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

10
red.py
View File

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