Cleaned up errors on shutdown
parent
cb4a173508
commit
f5a61e02c0
|
@ -1,5 +1,5 @@
|
|||
import asyncio
|
||||
from sys import stdout
|
||||
|
||||
from GeoffreyBot.geoffrey import *
|
||||
|
||||
|
||||
|
@ -15,11 +15,13 @@ def setup_logging():
|
|||
|
||||
|
||||
def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url):
|
||||
try:
|
||||
setup_logging()
|
||||
bot = GeoffreyBot(geoffrey_base_url, geoffrey_api_token)
|
||||
setup_logging()
|
||||
bot = GeoffreyBot(geoffrey_base_url, geoffrey_api_token)
|
||||
|
||||
bot.run(discord_token)
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
try:
|
||||
loop.run_until_complete(bot.start(discord_token))
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Bot received keyboard interrupt")
|
||||
|
@ -27,4 +29,5 @@ def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url):
|
|||
print(e)
|
||||
logger.info('Bot encountered the following unhandled exception %s', e)
|
||||
finally:
|
||||
loop.run_until_complete(bot.logout())
|
||||
logger.info("Bot shutting down...")
|
||||
|
|
|
@ -62,7 +62,6 @@ class GeoffreyBot(commands.Bot):
|
|||
await self.change_presence(activity=Game(self.default_status))
|
||||
|
||||
async def on_command(self, ctx):
|
||||
URL = self.base_url + '/api/command/{}'
|
||||
if ctx.invoked_subcommand is None:
|
||||
subcommand = ""
|
||||
else:
|
||||
|
@ -177,3 +176,4 @@ class GeoffreyBot(commands.Bot):
|
|||
help_dict[command_name] = help_list
|
||||
|
||||
return help_dict
|
||||
|
||||
|
|
Loading…
Reference in New Issue