-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
58 lines (49 loc) · 1.44 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
import os
import discord
from discord.ext import commands
import sqlite3
import traceback
import sys
import asyncpg
from asyncpg.pool import create_pool
import json
import keep_alive
with open ('config/botconfig.json', 'r') as f:
config = json.load(f)
token = config['token']
prefix = config['prefix']
database_url = config['database_url']
# for replit
'''
token = os.environ.get("token")
prefix = os.environ.get("prefix")
database_url = os.environ.get("database_url")
'''
intents = discord.Intents().all()
bot = commands.Bot(command_prefix=prefix, intents = discord.Intents.all())
bot.remove_command('help')
intents.members = True
#databse
async def create_db_pool():
bot.pg_con = await asyncpg.create_pool(database_url)
print("[\] DATABASE CONNECTED")
#Ready
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.idle, activity=discord.Activity(type=discord.ActivityType.watching, name="DMs for help") )
print("[\] BOT ONLNE")
#modules Importing
with open ('./config/modules.json', 'r') as f:
cogsData = json.load(f)
module = cogsData['extensions']
if __name__ == "__main__":
for values in module:
try:
bot.load_extension(values)
print(f"[/] loaded | {values}")
except:
print(f'Error loading {values}', file=sys.stderr)
traceback.print_exc()
keep_alive.keep_alive()
bot.loop.run_until_complete(create_db_pool())
bot.run(token)