-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (55 loc) · 1.91 KB
/
main.py
File metadata and controls
68 lines (55 loc) · 1.91 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
64
65
66
67
68
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
load_dotenv()
TOKEN = os.getenv("TOKEN")
PREFIX = os.getenv("PREFIX")
MONGO_URI = os.getenv("MONGO_URI")
if TOKEN is None:
print("Token not found in .env file.")
exit(1)
C = AsyncIOMotorClient(MONGO_URI)
class client(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
super().__init__(
command_prefix=commands.when_mentioned_or(PREFIX),
intents=intents,
help_command=None,
enable_debug_events=True,
)
self.client = client
self.cogslist = ["Cogs.Configuration.main", "Events.on_application"]
self.db = C["ServerApps"]
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")
await self.change_presence(
activity=discord.Activity(
name="Applications", type=discord.ActivityType.watching
)
)
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")
Client = client()
Client.run(TOKEN)