-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
65 lines (46 loc) · 1.39 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
import discord
from discord.ext import commands
import traceback
import sys
import json
import os
#logging
from commands.ready.logging_config import setup_logging
logger = setup_logging()
#for database
from commands.database.databaseCommands import create_pool
#try:
token = os.environ.get('token')
database_url = os.environ.get('database_url')
#except:
'''
with open ('config/config.json', 'r') as f:
config = json.load(f)
token = config['token']
prefix = config['prefix']
database_url = config['DATABASE_URL']
'''
bot = discord.Bot() #defining bot prefix
async def dbsetup():
# Create database connection pool
bot.pg_con = await create_pool(database_url)
@bot.event
async def on_ready():
await bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(type=discord.ActivityType.watching, name=f"Your shop")
)
logger.info("BOT Online!")
with open ('modules/modules.json', 'r') as data:
cog_data = json.load(data)
slashextension = cog_data['slashExtension']
if __name__ == "__main__":
for slashextensions in slashextension:
try:
bot.load_extension(slashextensions)
logger.info(f"[/] loaded | {slashextensions}")
except:
logger.error(f'Error loading {slashextensions}')
traceback.print_exc()
bot.loop.run_until_complete(dbsetup())
bot.run(f"{token}")