From ddca750093b795b14194ce95519ff7066fcd894e Mon Sep 17 00:00:00 2001 From: phixxy Date: Tue, 5 Nov 2024 17:33:11 -0800 Subject: [PATCH] removed unneeded xp_file.close() calls --- cogs/message_xp.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cogs/message_xp.py b/cogs/message_xp.py index 5e5bce5..32f99a7 100644 --- a/cogs/message_xp.py +++ b/cogs/message_xp.py @@ -34,24 +34,24 @@ class MessageXP(BotBaseCog): return else: #check if file exists - if not os.path.exists(self.data_dir + "xp.json"): + if not os.path.exists(os.path.join(self.data_dir, "xp.json")): create_xp_file(self) - with open(self.data_dir + "xp.json", "r") as xp_file: + + with open(os.path.join(self.data_dir, "xp.json"), "r") as xp_file: xp_data = json.load(xp_file) - xp_file.close() + if author_id in xp_data: xp_data[author_id] += 1 else: xp_data[author_id] = 1 - with open(self.data_dir + "xp.json", "w") as xp_file: - json.dump(xp_data, xp_file) - xp_file.close() + + with open(os.path.join(self.data_dir, "xp.json"), "w") as xp_file: + json.dump(xp_data, xp_file) def create_xp_file(self): with open(self.data_dir + "xp.json", "w") as xp_file: xp_data = {} json.dump(xp_data, xp_file) - xp_file.close() async def setup(bot):