mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Audio] Replace settings.json in case of corruption
This commit is contained in:
parent
4b032e48b9
commit
d349a0cab7
@ -6,6 +6,7 @@ from random import shuffle, choice
|
||||
from cogs.utils.dataIO import dataIO
|
||||
from cogs.utils import checks
|
||||
from __main__ import send_cmd_help, settings
|
||||
from json import JSONDecodeError
|
||||
import re
|
||||
import logging
|
||||
import collections
|
||||
@ -991,7 +992,7 @@ class Audio:
|
||||
self.settings["MAX_CACHE"] = size
|
||||
await self.bot.say("Max cache size set to {} MB.".format(size))
|
||||
self.save_settings()
|
||||
|
||||
|
||||
@audioset.command(name="emptydisconnect", pass_context=True)
|
||||
@checks.mod_or_permissions(manage_messages=True)
|
||||
async def audioset_emptydisconnect(self, ctx):
|
||||
@ -2087,7 +2088,13 @@ def check_files():
|
||||
print("Creating default audio settings.json...")
|
||||
dataIO.save_json(settings_path, default)
|
||||
else: # consistency check
|
||||
current = dataIO.load_json(settings_path)
|
||||
try:
|
||||
current = dataIO.load_json(settings_path)
|
||||
except JSONDecodeError:
|
||||
# settings.json keeps getting corrupted for unknown reasons. Let's
|
||||
# try to keep it from making the cog load fail.
|
||||
dataIO.save_json(settings_path, default)
|
||||
current = dataIO.load_json(settings_path)
|
||||
if current.keys() != default.keys():
|
||||
for key in default.keys():
|
||||
if key not in current.keys():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user