Backup settings on deletion (#163)

This commit is contained in:
tekulvw 2016-04-16 16:30:17 -04:00 committed by Twentysix
parent 95b5096961
commit 4fb5ba75b4

8
red.py
View File

@ -13,6 +13,8 @@ import sys
import logging import logging
import aiohttp import aiohttp
import importlib import importlib
import shutil
import traceback
# #
# Red, a Discord bot by Twentysix, based on discord.py and its command extension # Red, a Discord bot by Twentysix, based on discord.py and its command extension
@ -528,10 +530,12 @@ if __name__ == '__main__':
try: try:
loop.run_until_complete(main()) loop.run_until_complete(main())
except discord.LoginFailure: except discord.LoginFailure:
traceback.print_exc()
print("Invalid login credentials. Restart Red and configure it properly.") print("Invalid login credentials. Restart Red and configure it properly.")
shutil.copy('data/red/settings.json', 'data/red/settings.json-{}'.format(int(time.time())))
os.remove('data/red/settings.json') # Hopefully this won't backfire in case of discord servers' problems os.remove('data/red/settings.json') # Hopefully this won't backfire in case of discord servers' problems
except Exception as e: except:
print(e) traceback.print_exc()
loop.run_until_complete(bot.logout()) loop.run_until_complete(bot.logout())
finally: finally:
loop.close() loop.close()