-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbot.py
40 lines (31 loc) · 1.24 KB
/
bot.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
from discord.ext import commands
import asyncpg
import discord
import os
import json
with open ("data.json", "r") as f:
data = json.load(f)
token = data["token"]
db_pswd = data["db_pwd"]
# DB Connection
async def create_db_pool():
client.db = await asyncpg.create_pool(database="PostgreSQL-Tickets", user="postgres", password=db_pswd)
intents = discord.Intents().all()
client = commands.Bot(command_prefix="?", intents=intents, help_command=None, case_insensitive=True)
guild = discord.Guild
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
print("----------------------------------------")
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing, name=f"a system"))
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
try:
client.load_extension(f'cogs.{filename[:-3]}')
print(f'Loaded {filename}')
except Exception as e:
print(f'Failed to load {filename}')
print(f'[ERROR] {e}')
print("----------------------------------------")
client.loop.run_until_complete(create_db_pool())
client.run(token)