1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import logging
import os
import sys
import json
# create a pycord bot template
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__)
bot = commands.Bot(intents=discord.Intents.all())
@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.json'):
with open('settings.json', 'w') as f:
json.dump({
'volume': 1.0,
'audio_paths': ['audio', 'music', 'sounds']
}, f)
if os.path.exists('settings.json'):
try:
with open('settings.json') as f:
data = json.load(f)
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 e:
logger.error(f"Error loading settings.json: {e}")
with open('settings.json', '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.music.play',
'cogs.music.stop',
'cogs.music.join',
]
for i, extension in enumerate(extensions, 1):
bot.load_extension(extension)
logger.info(f"Loaded {i}/{len(extensions)} extensions")
bot.run(str(os.getenv("TOKEN")))
|