aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--main.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.py b/main.py
index efeb3a2..3ee86b2 100644
--- a/main.py
+++ b/main.py
@@ -8,6 +8,7 @@ import os
8import sys 8import sys
9import json 9import json
10import asyncio 10import asyncio
11import aiofiles
11import discord 12import discord
12from discord.ext import commands 13from discord.ext import commands
13from dotenv import load_dotenv 14from dotenv import load_dotenv
@@ -28,27 +29,29 @@ asyncio.set_event_loop(loop)
28 29
29bot = commands.Bot(intents=discord.Intents.all(), loop=loop) 30bot = commands.Bot(intents=discord.Intents.all(), loop=loop)
30 31
32settings = "settings.json"
33
31@bot.event 34@bot.event
32async def on_ready(): 35async def on_ready():
33 logger.info("ŁUKASZ SPERMA AKTYWACJA") 36 logger.info("ŁUKASZ SPERMA AKTYWACJA")
34 # send the message to channel ID 37 # send the message to channel ID
35 channel = bot.get_channel(1081667823799111804) 38 channel = bot.get_channel(1081667823799111804)
36 await channel.send("ŁUKASZ SPERMA AKTYWACJA") 39 await channel.send("ŁUKASZ SPERMA AKTYWACJA")
37 if not os.path.exists('settings.json'): 40 if not os.path.exists(settings):
38 with open('settings.json', 'w') as f: 41 async with aiofiles.open(settings, 'w') as f:
39 json.dump({ 42 json.dump({
40 'volume': 1.0, 43 'volume': 1.0,
41 'audio_paths': ['audio', 'music', 'sounds'] 44 'audio_paths': ['audio', 'music', 'sounds']
42 }, f) 45 }, f)
43 if os.path.exists('settings.json'): 46 if os.path.exists(settings):
44 try: 47 try:
45 with open('settings.json') as f: 48 async with aiofiles.open(settings) as f:
46 data = json.load(f) 49 data = json.load(f)
47 assert 'volume' in data and isinstance(data['volume'], float) 50 assert 'volume' in data and isinstance(data['volume'], float)
48 assert 'audio_paths' in data and isinstance(data['audio_paths'], list) 51 assert 'audio_paths' in data and isinstance(data['audio_paths'], list)
49 except (json.JSONDecodeError, AssertionError) as error: 52 except (json.JSONDecodeError, AssertionError) as error:
50 logger.error(f"Error loading settings.json: {error}") 53 logger.error(f"Error loading settings.json: {error}")
51 with open('settings.json', 'w') as f: 54 async with aiofiles.open(settings, 'w') as f:
52 json.dump({ 55 json.dump({
53 'volume': 1.0, 56 'volume': 1.0,
54 'audio_paths': ['audio', 'music', 'sounds'] 57 'audio_paths': ['audio', 'music', 'sounds']
@@ -69,7 +72,7 @@ if __name__ == "__main__":
69 'cogs.downloader', 72 'cogs.downloader',
70 'cogs.say', 73 'cogs.say',
71 'cogs.jarvis', 74 'cogs.jarvis',
72 'cogs.music.play', 75 'cogs.music.play_commands',
73 'cogs.music.stop', 76 'cogs.music.stop',
74 'cogs.music.join', 77 'cogs.music.join',
75 ] 78 ]