aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-03-18 15:29:51 +0100
committersalmonik <raisersoft@proton.me>2026-03-18 15:29:51 +0100
commitc0053ca98912901b5d387d58fbc57f9b7da91f38 (patch)
tree14fe7a7beae1ca2745333dcd7032a6ced28de0f7 /main.py
parentfix tts (diff)
downloadsenator-sperma-c0053ca98912901b5d387d58fbc57f9b7da91f38.tar.gz
senator-sperma-c0053ca98912901b5d387d58fbc57f9b7da91f38.zip
voice doesn't work due to DAVE, but we got copyparty search
Diffstat (limited to '')
-rw-r--r--main.py47
1 files changed, 34 insertions, 13 deletions
diff --git a/main.py b/main.py
index eaac7fe..f1cbff7 100644
--- a/main.py
+++ b/main.py
@@ -13,6 +13,8 @@ import discord
13from discord.ext import commands 13from discord.ext import commands
14from dotenv import load_dotenv 14from dotenv import load_dotenv
15 15
16from cogs.voice import get_voice_manager
17
16# Configure logging 18# Configure logging
17logging.basicConfig( 19logging.basicConfig(
18 level=logging.INFO, 20 level=logging.INFO,
@@ -27,7 +29,11 @@ logger = logging.getLogger(__name__)
27loop = asyncio.new_event_loop() 29loop = asyncio.new_event_loop()
28asyncio.set_event_loop(loop) 30asyncio.set_event_loop(loop)
29 31
30bot = commands.Bot(intents=discord.Intents.all(), loop=loop) 32intents = discord.Intents.default()
33intents.voice_states = True
34intents.guilds = True
35intents.messages = True
36bot = commands.Bot(intents=intents, loop=loop)
31 37
32settings = "settings.json" 38settings = "settings.json"
33 39
@@ -37,27 +43,40 @@ async def on_ready():
37 # send the message to channel ID 43 # send the message to channel ID
38 channel = bot.get_channel(1081667823799111804) 44 channel = bot.get_channel(1081667823799111804)
39 await channel.send("ŁUKASZ SPERMA AKTYWACJA") 45 await channel.send("ŁUKASZ SPERMA AKTYWACJA")
46
47 # Create settings.json if it doesn't exist
40 if not os.path.exists(settings): 48 if not os.path.exists(settings):
49 default_settings = {
50 'volume': 1.0,
51 'file_paths': ['audio', 'music', 'sounds', 'videos', 'images'],
52 'baseurl': 'http://localhost:8080'
53 }
41 async with aiofiles.open(settings, 'w') as f: 54 async with aiofiles.open(settings, 'w') as f:
42 json.dump({ 55 await f.write(json.dumps(default_settings, indent=2))
43 'volume': 1.0, 56 logger.info("settings.json created")
44 'audio_paths': ['audio', 'music', 'sounds'] 57
45 }, f) 58 # Validate and fix settings.json if it exists
46 if os.path.exists(settings): 59 if os.path.exists(settings):
47 try: 60 try:
48 async with aiofiles.open(settings) as f: 61 async with aiofiles.open(settings, 'r') as f:
49 content = await f.read() 62 content = await f.read()
63 if not content.strip():
64 raise json.JSONDecodeError("Empty file", "", 0)
50 data = json.loads(content) 65 data = json.loads(content)
51 assert 'volume' in data and isinstance(data['volume'], float) 66 assert 'volume' in data and isinstance(data['volume'], float)
52 assert 'audio_paths' in data and isinstance(data['audio_paths'], list) 67 assert 'file_paths' in data and isinstance(data['file_paths'], list)
68 assert 'baseurl' in data and isinstance(data['baseurl'], str)
53 except (json.JSONDecodeError, AssertionError) as error: 69 except (json.JSONDecodeError, AssertionError) as error:
54 logger.error(f"Error loading settings.json: {error}") 70 logger.error(f"Error loading settings.json: {error}")
71 default_settings = {
72 'volume': 1.0,
73 'file_paths': ['audio', 'music', 'sounds', 'videos', 'images'],
74 'baseurl': 'http://localhost:8080'
75 }
55 async with aiofiles.open(settings, 'w') as f: 76 async with aiofiles.open(settings, 'w') as f:
56 json.dump({ 77 await f.write(json.dumps(default_settings, indent=2))
57 'volume': 1.0, 78 logger.info("settings.json recreated")
58 'audio_paths': ['audio', 'music', 'sounds'] 79
59 }, f)
60 logger.info("settings.json created")
61 80
62 81
63if __name__ == "__main__": 82if __name__ == "__main__":
@@ -69,13 +88,14 @@ if __name__ == "__main__":
69 'cogs.web', 88 'cogs.web',
70 'cogs.ai', 89 'cogs.ai',
71 'cogs.conversion', 90 'cogs.conversion',
72 'cogs.math', 91 'cogs.math_commands',
73 'cogs.downloader', 92 'cogs.downloader',
74 'cogs.say', 93 'cogs.say',
75 'cogs.jarvis', 94 'cogs.jarvis',
76 'cogs.music.play_commands', 95 'cogs.music.play_commands',
77 'cogs.music.stop', 96 'cogs.music.stop',
78 'cogs.music.join', 97 'cogs.music.join',
98 'cogs.search',
79 ] 99 ]
80 100
81 try: 101 try:
@@ -89,6 +109,7 @@ if __name__ == "__main__":
89 raise ValueError("No token provided. Please set the TOKEN environment variable.") 109 raise ValueError("No token provided. Please set the TOKEN environment variable.")
90 110
91 bot.run(token) 111 bot.run(token)
112
92 except Exception as e: 113 except Exception as e:
93 logger.error(f"Error starting the bot: {e}") 114 logger.error(f"Error starting the bot: {e}")
94 sys.exit(1) 115 sys.exit(1)