From c0053ca98912901b5d387d58fbc57f9b7da91f38 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 18 Mar 2026 15:29:51 +0100 Subject: voice doesn't work due to DAVE, but we got copyparty search --- main.py | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index eaac7fe..f1cbff7 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,8 @@ import discord from discord.ext import commands from dotenv import load_dotenv +from cogs.voice import get_voice_manager + # Configure logging logging.basicConfig( level=logging.INFO, @@ -27,7 +29,11 @@ logger = logging.getLogger(__name__) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) -bot = commands.Bot(intents=discord.Intents.all(), loop=loop) +intents = discord.Intents.default() +intents.voice_states = True +intents.guilds = True +intents.messages = True +bot = commands.Bot(intents=intents, loop=loop) settings = "settings.json" @@ -37,27 +43,40 @@ async def on_ready(): # send the message to channel ID channel = bot.get_channel(1081667823799111804) await channel.send("ƁUKASZ SPERMA AKTYWACJA") + + # Create settings.json if it doesn't exist if not os.path.exists(settings): + default_settings = { + 'volume': 1.0, + 'file_paths': ['audio', 'music', 'sounds', 'videos', 'images'], + 'baseurl': 'http://localhost:8080' + } async with aiofiles.open(settings, 'w') as f: - json.dump({ - 'volume': 1.0, - 'audio_paths': ['audio', 'music', 'sounds'] - }, f) + await f.write(json.dumps(default_settings, indent=2)) + logger.info("settings.json created") + + # Validate and fix settings.json if it exists if os.path.exists(settings): try: - async with aiofiles.open(settings) as f: + async with aiofiles.open(settings, 'r') as f: content = await f.read() + if not content.strip(): + raise json.JSONDecodeError("Empty file", "", 0) data = json.loads(content) assert 'volume' in data and isinstance(data['volume'], float) - assert 'audio_paths' in data and isinstance(data['audio_paths'], list) + assert 'file_paths' in data and isinstance(data['file_paths'], list) + assert 'baseurl' in data and isinstance(data['baseurl'], str) except (json.JSONDecodeError, AssertionError) as error: logger.error(f"Error loading settings.json: {error}") + default_settings = { + 'volume': 1.0, + 'file_paths': ['audio', 'music', 'sounds', 'videos', 'images'], + 'baseurl': 'http://localhost:8080' + } async with aiofiles.open(settings, 'w') as f: - json.dump({ - 'volume': 1.0, - 'audio_paths': ['audio', 'music', 'sounds'] - }, f) - logger.info("settings.json created") + await f.write(json.dumps(default_settings, indent=2)) + logger.info("settings.json recreated") + if __name__ == "__main__": @@ -69,13 +88,14 @@ if __name__ == "__main__": 'cogs.web', 'cogs.ai', 'cogs.conversion', - 'cogs.math', + 'cogs.math_commands', 'cogs.downloader', 'cogs.say', 'cogs.jarvis', 'cogs.music.play_commands', 'cogs.music.stop', 'cogs.music.join', + 'cogs.search', ] try: @@ -89,6 +109,7 @@ if __name__ == "__main__": raise ValueError("No token provided. Please set the TOKEN environment variable.") bot.run(token) + except Exception as e: logger.error(f"Error starting the bot: {e}") sys.exit(1) -- cgit v1.2.3