From 840a7e6eedbf8791f455d7085a8180f586d42266 Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 14 Mar 2017 17:46:23 +0100 Subject: attempt search without region, use new joblib --- joblib | 2 +- main.py | 38 +++++++++++++++----------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/joblib b/joblib index 542df39..7ced841 160000 --- a/joblib +++ b/joblib @@ -1 +1 @@ -Subproject commit 542df395ce186ccc28d2c4122b7b12024ade8f47 +Subproject commit 7ced841aa44a7dd7bd2d3a68ceb989ef488ce441 diff --git a/main.py b/main.py index f46fa73..2f5d733 100644 --- a/main.py +++ b/main.py @@ -57,31 +57,9 @@ async def on_ready(): name="alpha.vainsocial.com")) -@bot.event -async def on_command_error(error, ctx): - logging.error(error) - if ctx.invoked_subcommand: - pages = bot.formatter.format_help_for( - ctx, ctx.invoked_subcommand) - for page in pages: - await bot.send_message( - ctx.message.channel, page) - else: - pages = bot.formatter.format_help_for( - ctx, ctx.command) - for page in pages: - await bot.send_message( - ctx.message.channel, page) - - @bot.command() -async def vainsocial(name: str, region: str): +async def vainsocial(name: str, region: str = None): """Retrieves a player's stats.""" - region = region.lower() - if region not in ["na", "eu", "sg", "ea", "sa"]: - await bot.say("That region is not supported.") - return - query = """ SELECT player.name, @@ -153,6 +131,20 @@ async def vainsocial(name: str, region: str): lmcd = data["last_match_created_date"] msgid = await bot.say(embed=emb(data)) + if not in_cache: + if region is None: + await bot.edit_message(msgid, + "Can't find you. What is your region?") + return + region = region.lower() + if region not in ["na", "eu", "sg", "ea", "sa"]: + await bot.edit_message(msgid, + "That region is not supported.") + return + else: + if region is None: + region = data["shard_id"] + logging.info("'%s' cached: %s", name, in_cache) payload = { -- cgit v1.3.1