-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (61 loc) · 2.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
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
73
import discord
import sys
sys.dont_write_bytecode = True
import discord
from discord.ext import commands
from dotenv import load_dotenv
import os
import time
import platform
from motor.motor_asyncio import AsyncIOMotorClient
from roblox import Client
load_dotenv()
TOKEN = os.getenv("TOKEN")
PREFIX = os.getenv("PREFIX")
MONGO_URL = os.getenv("MONGO_URL")
client = AsyncIOMotorClient(MONGO_URL)
class Client(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
# --- DB
self.db = client["TriMelERM"]
self.shifts = self.db["Shifts"]
self.moderations = self.db["Moderations"]
self.abscenses = self.db["Abscenses"]
# ---
super().__init__(
command_prefix=commands.when_mentioned_or(PREFIX), intents=intents
)
self.client = client
self.cogslist = [
"Modules.moderations",
"Events.on_moderation",
"Events.on_moderation_edit",
"Events.on_shift_start",
"Events.on_shift_end",
"Events.on_shift_break",
"Events.on_shift_resume",
"Modules.shifts",
"Modules.absenses",
"Events.on_loa_end",
]
async def load_jishaku(self):
await self.wait_until_ready()
await self.load_extension("jishaku")
async def on_ready(self):
prfx = time.strftime("%H:%M:%S GMT", time.gmtime())
print(prfx + " Logged in as " + self.user.name)
print(prfx + " Bot ID " + str(self.user.id))
print(prfx + " Discord Version " + discord.__version__)
print(prfx + " Python Version " + str(platform.python_version()))
synced = await self.tree.sync()
print(prfx + " Slash CMDs Synced " + str(len(synced)) + " Commands")
print(prfx + " Bot is in " + str(len(self.guilds)) + " servers")
async def setup_hook(self):
self.loop.create_task(self.load_jishaku())
for ext in self.cogslist:
await self.load_extension(ext)
print(f"{ext} loaded")
c = Client()
c.run(TOKEN)