-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (43 loc) · 1.4 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
import asyncio
import discord
import asyncpg
from discord.ext import commands
from json import load
from database.database_main import Database
from discord_components import DiscordComponents, Button
class EconomyBot(commands.Bot):
def __init__(self, loop):
super().__init__(
command_prefix="$",
intents = discord.Intents.all(),
activity = discord.Game("$help"),
help_command=commands.MinimalHelpCommand()
)
async def on_connect(self):
DiscordComponents(bot)
#Connect to Database
self.db = Database()
await self.db.create_pool()
print("Database Connected")
print("Bot Connected")
async def on_disconnect(self):
await self.close()
print("Bot Disconnected")
async def on_ready(self):
#Load cogs
cogs = ["cogs.game", "cogs.player", "cogs.error_handling", "cogs.admin", "cogs.mini_games"]
for cog in cogs:
self.load_extension(cog)
print("Cogs Loaded")
print("Bot Ready")
if __name__ == "__main__":
#Load Discord Token
with open("token.json", "r") as file:
TOKEN = load(file)["token"]
loop = asyncio.get_event_loop()
bot = EconomyBot(loop)
try:
loop.run_until_complete(bot.start(TOKEN))
except KeyboardInterrupt:
print("Closing Loop")
loop.close()