diff options
| author | salmonik <raisersoft@proton.me> | 2026-03-18 15:29:51 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-03-18 15:29:51 +0100 |
| commit | c0053ca98912901b5d387d58fbc57f9b7da91f38 (patch) | |
| tree | 14fe7a7beae1ca2745333dcd7032a6ced28de0f7 /main.py | |
| parent | fix tts (diff) | |
| download | senator-sperma-c0053ca98912901b5d387d58fbc57f9b7da91f38.tar.gz senator-sperma-c0053ca98912901b5d387d58fbc57f9b7da91f38.zip | |
voice doesn't work due to DAVE, but we got copyparty search
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 47 |
1 files changed, 34 insertions, 13 deletions
| @@ -13,6 +13,8 @@ import discord | |||
| 13 | from discord.ext import commands | 13 | from discord.ext import commands |
| 14 | from dotenv import load_dotenv | 14 | from dotenv import load_dotenv |
| 15 | 15 | ||
| 16 | from cogs.voice import get_voice_manager | ||
| 17 | |||
| 16 | # Configure logging | 18 | # Configure logging |
| 17 | logging.basicConfig( | 19 | logging.basicConfig( |
| 18 | level=logging.INFO, | 20 | level=logging.INFO, |
| @@ -27,7 +29,11 @@ logger = logging.getLogger(__name__) | |||
| 27 | loop = asyncio.new_event_loop() | 29 | loop = asyncio.new_event_loop() |
| 28 | asyncio.set_event_loop(loop) | 30 | asyncio.set_event_loop(loop) |
| 29 | 31 | ||
| 30 | bot = commands.Bot(intents=discord.Intents.all(), loop=loop) | 32 | intents = discord.Intents.default() |
| 33 | intents.voice_states = True | ||
| 34 | intents.guilds = True | ||
| 35 | intents.messages = True | ||
| 36 | bot = commands.Bot(intents=intents, loop=loop) | ||
| 31 | 37 | ||
| 32 | settings = "settings.json" | 38 | settings = "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 | ||
| 63 | if __name__ == "__main__": | 82 | if __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) |
