-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (47 loc) · 1.59 KB
/
main.py
File metadata and controls
63 lines (47 loc) · 1.59 KB
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
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
from commands import handle_commands
from logs import logs
from ConfigLoader import load_config
load_dotenv()
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
CONFIG = load_config()
# Intents
intents = discord.Intents.default()
intents.message_content = True
intents.presences = True
intents.members = True
intents.messages = True
DEV_GUILD_ID = 1254318703554723901
# Bot class
class MyBot(commands.Bot):
def __init__(self):
super().__init__(
command_prefix=CONFIG["general"]["prefix"],
intents=intents
)
async def setup_hook(self):
guild = discord.Object(id=DEV_GUILD_ID)
self.tree.copy_global_to(guild=guild)
await self.tree.sync(guild=guild)
bot = MyBot()
handle_commands(bot)
logs(bot, CONFIG=CONFIG)
# Events
@bot.event
async def on_ready():
status_type = CONFIG["general"]["status_type"].lower()
status_text = CONFIG["general"]["status_text"]
if status_type == "playing":
activity = discord.Game(name=status_text)
elif status_type == "watching":
activity = discord.Activity(type=discord.ActivityType.watching, name=status_text)
elif status_type == "listening":
activity = discord.Activity(type=discord.ActivityType.listening, name=status_text)
else:
raise ValueError(f"Invalid status_type in config.yml: {status_type}")
await bot.change_presence(activity=activity, status=discord.Status.online)
print("Applied presence from config:", status_type, status_text)
bot.run(DISCORD_TOKEN)