From 1017fb648b1114106abe596663d26aa23fe12805 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 20 Feb 2026 18:35:36 +0100 Subject: fix settings file nagging --- cogs/vclogs.py | 14 +++++++------- main.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cogs/vclogs.py b/cogs/vclogs.py index bc317a4..0d8ca3b 100644 --- a/cogs/vclogs.py +++ b/cogs/vclogs.py @@ -25,8 +25,8 @@ class VcLogs(commands.Cog): @staticmethod def settings_check(): - if not os.path.exists(settings_file): - with open(settings_file, 'w') as f: + if not os.path.exists(VcLogs.settings_file): + with open(VcLogs.settings_file, 'w') as f: json.dump({'volume': '5'}, f, indent=4) logger.info("settings.json created") @@ -67,8 +67,8 @@ class VcLogs(commands.Cog): tts = gTTS(text=text, lang='pl') tts.save(tts_file) - if os.path.exists(settings_file): - async with aiofiles.open(settings_file) as f: + if os.path.exists(VcLogs.settings_file): + async with aiofiles.open(VcLogs.settings_file) as f: data = json.load(f) volume = data['volume'] else: @@ -95,11 +95,11 @@ class VcLogs(commands.Cog): ) async def volume(self, ctx: discord.ApplicationContext, volume: int): try: - if not os.path.exists(settings_file): - async with aiofiles.open(settings_file, 'w') as f: + if not os.path.exists(VcLogs.settings_file): + async with aiofiles.open(VcLogs.settings_file, 'w') as f: json.dump({'volume': '5'}, f, indent=4) logger.info("settings.json created") - async with aiofiles.open(settings_file, 'w') as f: + async with aiofiles.open(VcLogs.settings_file, 'w') as f: json.dump({"volume": volume}, f, indent=4) await ctx.followup.send(f"Volume has been set to: {volume}") logger.info(f"Volume changed to: {volume}") diff --git a/main.py b/main.py index 3ee86b2..eaac7fe 100644 --- a/main.py +++ b/main.py @@ -46,7 +46,8 @@ async def on_ready(): if os.path.exists(settings): try: async with aiofiles.open(settings) as f: - data = json.load(f) + content = await f.read() + data = json.loads(content) assert 'volume' in data and isinstance(data['volume'], float) assert 'audio_paths' in data and isinstance(data['audio_paths'], list) except (json.JSONDecodeError, AssertionError) as error: -- cgit v1.2.3