From c9281f734b7610b580c6ab87232b7a328d655ffd Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 5 Mar 2018 18:28:37 -0500 Subject: [PATCH] [V3 Config] Fix clear throwing errors (#1374) --- redbot/core/drivers/red_json.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/redbot/core/drivers/red_json.py b/redbot/core/drivers/red_json.py index dec2a5f58..5471d4246 100644 --- a/redbot/core/drivers/red_json.py +++ b/redbot/core/drivers/red_json.py @@ -62,10 +62,11 @@ class JSON(BaseDriver): async def clear(self, *identifiers: str): partial = self.data full_identifiers = (self.unique_cog_identifier, *identifiers) - for i in full_identifiers[:-1]: - if i not in partial: - break - partial = partial[i] - else: + try: + for i in full_identifiers[:-1]: + partial = partial[i] del partial[identifiers[-1]] - await self.jsonIO._threadsafe_save_json(self.data) + except KeyError: + pass + else: + await self.jsonIO._threadsafe_save_json(self.data)