mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2025-01-14 16:14:07 +01:00
Added commands I think
This commit is contained in:
parent
779f89518b
commit
358647fc48
@ -11,8 +11,7 @@ logging.getLogger('TitanBot')
|
|||||||
logging.getLogger('sqlalchemy')
|
logging.getLogger('sqlalchemy')
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=config['command-prefix'])
|
bot = commands.Bot(command_prefix=config['command-prefix'])
|
||||||
database = DatabaseInterface(bot)
|
database = none
|
||||||
|
|
||||||
def _cleanup():
|
def _cleanup():
|
||||||
try:
|
try:
|
||||||
bot.loop.run_until_complete(logout())
|
bot.loop.run_until_complete(logout())
|
||||||
@ -39,11 +38,11 @@ async def on_ready(self):
|
|||||||
game=discord.Game(name="Embed your Discord server! Visit https://TitanEmbeds.tk/"), status=discord.Status.online
|
game=discord.Game(name="Embed your Discord server! Visit https://TitanEmbeds.tk/"), status=discord.Status.online
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await self.database.connect(config["database-uri"] + "?charset=utf8mb4")
|
database = DatabaseInterface(bot, config["database-uri"] + "?charset=utf8mb4")
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.error("Unable to connect to specified database!")
|
self.logger.error("Unable to connect to specified database!")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
await self.logout()
|
await bot.logout()
|
||||||
return
|
return
|
||||||
if "no-init" not in sys.argv:
|
if "no-init" not in sys.argv:
|
||||||
for server in bot.servers:
|
for server in bot.servers:
|
||||||
|
@ -18,13 +18,9 @@ from titanembeds.database.unauthenticated_bans import UnauthenticatedBans
|
|||||||
|
|
||||||
class DatabaseInterface(object):
|
class DatabaseInterface(object):
|
||||||
# Courtesy of https://github.com/SunDwarf/Jokusoramame
|
# Courtesy of https://github.com/SunDwarf/Jokusoramame
|
||||||
def __init__(self, bot):
|
async def __init__(self, bot, dburi):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
self.engine = None # type: Engine
|
|
||||||
self._sessionmaker = None # type: sessionmaker
|
|
||||||
|
|
||||||
async def connect(self, dburi):
|
|
||||||
async with threadpool():
|
async with threadpool():
|
||||||
self.engine = create_engine(dburi, pool_recycle=10)
|
self.engine = create_engine(dburi, pool_recycle=10)
|
||||||
self._sessionmaker = sessionmaker(bind=self.engine, expire_on_commit=False)
|
self._sessionmaker = sessionmaker(bind=self.engine, expire_on_commit=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user