# This file is part of Senator Sperma # Licensed under the GPL-3.0 License # Copyright (C) 2026 Salmonik @ salmonik@tuta.io # https://codeberg.org/salmonik/senator-sperma import logging import os import sys import json import asyncio import aiofiles import discord from discord.ext import commands from dotenv import load_dotenv # Configure logging logging.basicConfig( level=logging.INFO, format='%(levelname)s - %(filename)s - %(name)s - %(message)s', handlers=[ logging.StreamHandler(sys.stdout) ] ) logger = logging.getLogger(__name__) # Create a new event loop and set it as the current loop loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) bot = commands.Bot(intents=discord.Intents.all(), loop=loop) settings = "settings.json" @bot.event async def on_ready(): logger.info("ŁUKASZ SPERMA AKTYWACJA") # send the message to channel ID channel = bot.get_channel(1081667823799111804) await channel.send("ŁUKASZ SPERMA AKTYWACJA") if not os.path.exists(settings): async with aiofiles.open(settings, 'w') as f: json.dump({ 'volume': 1.0, 'audio_paths': ['audio', 'music', 'sounds'] }, f) if os.path.exists(settings): try: async with aiofiles.open(settings) as 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: logger.error(f"Error loading settings.json: {error}") async with aiofiles.open(settings, 'w') as f: json.dump({ 'volume': 1.0, 'audio_paths': ['audio', 'music', 'sounds'] }, f) logger.info("settings.json created") if __name__ == "__main__": load_dotenv() extensions = [ "cogs.vclogs", "cogs.compression", 'cogs.tts', 'cogs.web', 'cogs.ai', 'cogs.conversion', 'cogs.math', 'cogs.downloader', 'cogs.say', 'cogs.jarvis', 'cogs.music.play_commands', 'cogs.music.stop', 'cogs.music.join', ] try: for i, extension in enumerate(extensions, 1): bot.load_extension(extension) logger.info(f"Loaded {i}/{len(extensions)} extensions") # Run the bot with the token from environment variables token = os.getenv("TOKEN") if not token: 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)