-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (28 loc) · 858 Bytes
/
main.py
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
import asyncio
import logging
import os
import threading
import discord
from client import MyClient
from commands import img, txt
from job_handler import JobQueue, job_selector
# setup logging
logging.basicConfig(
level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s"
)
# initialize intents and discord client
intents = discord.Intents.default()
client = MyClient(intents=intents)
# setup the job queue
job_queue = JobQueue()
job_thread = threading.Thread(
target=asyncio.run, args=(job_queue.run_jobs(client, job_selector),)
)
job_thread.daemon = True
job_thread.start()
# register the commands in the command tree
client.tree.command()(img.create_command_with(job_queue))
client.tree.command()(txt.create_command_with(job_queue))
# get the token and start the bot
TOKEN = os.environ.get("DISCORD_BOT_TOKEN")
client.run(TOKEN)