Cleaned up startup and made `?selling` prettier
parent
cc03b0f0e6
commit
5146f2cb80
|
@ -16,11 +16,13 @@ def setup_logging():
|
|||
|
||||
def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url):
|
||||
setup_logging()
|
||||
loop = None
|
||||
bot = None
|
||||
|
||||
try:
|
||||
bot = GeoffreyBot(geoffrey_base_url, geoffrey_api_token)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
try:
|
||||
loop.run_until_complete(bot.start(discord_token))
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
@ -29,5 +31,6 @@ def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url):
|
|||
print(e)
|
||||
logger.info('Bot encountered the following unhandled exception %s', e)
|
||||
finally:
|
||||
if loop and bot:
|
||||
loop.run_until_complete(bot.logout())
|
||||
logger.info("Bot shutting down...")
|
||||
|
|
|
@ -20,8 +20,17 @@ def format_message(msg_format, *args):
|
|||
|
||||
|
||||
def formatted_item_listing(item):
|
||||
return format_message("{} {} for {}D, restocked {} day(s) ago", item["amount"], item["item_name"],
|
||||
item["price"], item["days_since_restock"])
|
||||
days = int(item["days_since_restock"])
|
||||
|
||||
if days == 0:
|
||||
days_stocked = "today"
|
||||
elif days == 1:
|
||||
days_stocked = "yesterday"
|
||||
else:
|
||||
days_stocked = "{} days ago".format(days)
|
||||
|
||||
return format_message("{} {} for {}D, restocked {}", item["amount"], item["item_name"],
|
||||
item["price"], days_stocked)
|
||||
|
||||
|
||||
def formatted_location(location):
|
||||
|
|
Loading…
Reference in New Issue