-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (33 loc) · 1.09 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
from events.on_ready_event import on_ready_event
from commands import main_command_setter as commands_main
from scheduler.LeetCode import sendPOTD
from scheduler.LeetCode import sendSolution
from scheduler.Codeforces import sendContestEmbed
from nextcord.ext import tasks
from dotenv import load_dotenv
from discordBot import init_bot
import os
import asyncio
load_dotenv()
TOKEN = os.environ.get("TOKEN")
POTD_CHANNEL = os.environ.get("POTD_CHANNEL")
CONTEST_CHANNEL = os.environ.get("CONTEST_CHANNEL")
bot = init_bot()
# =========Importing Commands=======
commands_main.setup_all_commands(bot)
# =========Tasks Loop=========
@tasks.loop(hours=24)
async def sendPOTDLoop():
problem_id = await sendPOTD(bot, POTD_CHANNEL)
await asyncio.sleep(43200) # ! Sleeping for 12 hours
await sendSolution(bot, POTD_CHANNEL, problem_id)
@tasks.loop(hours=24)
async def sendContestLoop():
await sendContestEmbed(bot, CONTEST_CHANNEL)
@bot.event
async def on_ready():
await on_ready_event(bot)
sendPOTDLoop.start()
sendContestLoop.start()
if __name__ == "__main__":
bot.run(TOKEN)