Added commands I think

This commit is contained in:
JustMaffie 2017-05-27 23:51:41 +02:00
parent 0b0662e06c
commit fd26f5cc99

View File

@ -11,7 +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'])
aiosession = aiohttp.ClientSession(loop=loop) aiosession = aiohttp.ClientSession(loop=bot.loop)
http.user_agent += ' TitanEmbeds-Bot' http.user_agent += ' TitanEmbeds-Bot'
database = DatabaseInterface() database = DatabaseInterface()
@ -19,7 +19,7 @@ initFirst()
def run(self): def run(self):
try: try:
self.loop.run_until_complete(self.start(config["bot-token"])) bot.loop.run_until_complete(self.start(config["bot-token"]))
except discord.errors.LoginFailure: except discord.errors.LoginFailure:
print("Invalid bot token in config!") print("Invalid bot token in config!")
finally: finally:
@ -27,18 +27,18 @@ def run(self):
self._cleanup() self._cleanup()
except Exception as e: except Exception as e:
print("Error in cleanup:", e) print("Error in cleanup:", e)
self.loop.close() bot.loop.close()
def _cleanup(self): def _cleanup(self):
try: try:
self.loop.run_until_complete(self.logout()) bot.loop.run_until_complete(self.logout())
except: # Can be ignored except: # Can be ignored
pass pass
pending = asyncio.Task.all_tasks() pending = asyncio.Task.all_tasks()
gathered = asyncio.gather(*pending) gathered = asyncio.gather(*pending)
try: try:
gathered.cancel() gathered.cancel()
self.loop.run_until_complete(gathered) bot.loop.run_until_complete(gathered)
gathered.exception() gathered.exception()
except: # Can be ignored except: # Can be ignored
pass pass