|
|
@ -12,11 +12,11 @@
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import datetime
|
|
|
|
import datetime
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import random
|
|
|
|
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import aiohttp
|
|
|
|
import aiohttp
|
|
|
|
import asyncpg as asyncpg
|
|
|
|
import asyncpg as asyncpg
|
|
|
@ -49,8 +49,6 @@ API_TOKEN = config('DISCORD_TOKEN')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Bot(commands.Bot):
|
|
|
|
class Bot(commands.Bot):
|
|
|
|
threadLock = threading.Lock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, **options):
|
|
|
|
def __init__(self, **options):
|
|
|
|
|
|
|
|
|
|
|
|
async def get_prefix(bot, message):
|
|
|
|
async def get_prefix(bot, message):
|
|
|
@ -90,7 +88,6 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
async def create_connection():
|
|
|
|
async def create_connection():
|
|
|
|
"""Setting up connection using asyncpg"""
|
|
|
|
"""Setting up connection using asyncpg"""
|
|
|
|
with self.threadLock:
|
|
|
|
|
|
|
|
self.db = await asyncpg.create_pool(
|
|
|
|
self.db = await asyncpg.create_pool(
|
|
|
|
host=host,
|
|
|
|
host=host,
|
|
|
|
port=int(port),
|
|
|
|
port=int(port),
|
|
|
@ -135,8 +132,11 @@ class Bot(commands.Bot):
|
|
|
|
# Release connection back to pool
|
|
|
|
# Release connection back to pool
|
|
|
|
await pool.release(conn)
|
|
|
|
await pool.release(conn)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
loop.run_until_complete(create_connection())
|
|
|
|
|
|
|
|
|
|
|
|
# Establish Database Connection
|
|
|
|
# Establish Database Connection
|
|
|
|
self.loop.run_until_complete(create_connection())
|
|
|
|
# self.loop.run_until_complete(create_connection())
|
|
|
|
# Load Information Into Cache
|
|
|
|
# Load Information Into Cache
|
|
|
|
self.loop.run_until_complete(startup_cache_log())
|
|
|
|
self.loop.run_until_complete(startup_cache_log())
|
|
|
|
|
|
|
|
|
|
|
|