-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.py
57 lines (41 loc) · 1.27 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 discord
from discord.ext import commands
import traceback
import sys
import json
import requests
from discord_components import *
#for database
import asyncpg
from asyncpg.pool import create_pool
import sqlite3
with open ('config/config.json', 'r') as f:
config = json.load(f)
token = config['token']
prefix = config['prefix']
database_url = config['database_url']
bot = commands.Bot(command_prefix=f'{prefix}') #defining bot prefix
bot.remove_command('help')
async def create_db_pool():
bot.pg_con = await asyncpg.create_pool(f"{database_url}")
print("DATABASE | Connected")
@bot.event
async def on_ready():
await bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(type=discord.ActivityType.watching, name=f"{prefix}help")
)
print("Bot online!")
DiscordComponents(bot)
with open ('extension/extension.json', 'r') as data:
cog_data = json.load(data)
extension = cog_data['extension']
if __name__ == "__main__":
for extension in extension:
try:
bot.load_extension(extension)
except:
print(f'Error loading {extension}', file=sys.stderr)
traceback.print_exc()
bot.loop.run_until_complete(create_db_pool())
bot.run(f"{token}")