summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-03-14 17:46:23 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-03-14 17:46:23 +0100
commit840a7e6eedbf8791f455d7085a8180f586d42266 (patch)
tree51ec6eb2c10866a6bca59ec10029efbad6299173
parent71f02da10610bff99532663d698e66bffc7ba5fd (diff)
downloaddiscordbot-840a7e6eedbf8791f455d7085a8180f586d42266.tar.gz
discordbot-840a7e6eedbf8791f455d7085a8180f586d42266.zip
attempt search without region, use new joblib
m---------joblib0
-rw-r--r--main.py38
2 files changed, 15 insertions, 23 deletions
diff --git a/joblib b/joblib
-Subproject 542df395ce186ccc28d2c4122b7b12024ade8f4
+Subproject 7ced841aa44a7dd7bd2d3a68ceb989ef488ce44
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 = {