The lookup for the profile info takes a while, sent a message before it starts
This commit is contained in:
parent
7a6861c4c5
commit
9eebb9361d
|
@ -4,6 +4,7 @@ from discord.ext import commands
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
|
||||||
base_url = "https://owapi.net/api/v2/u/"
|
base_url = "https://owapi.net/api/v2/u/"
|
||||||
|
@ -20,6 +21,7 @@ class Overwatch:
|
||||||
@ow.command(pass_context=True, name="add")
|
@ow.command(pass_context=True, name="add")
|
||||||
async def add(self, ctx, username: str):
|
async def add(self, ctx, username: str):
|
||||||
username = username.replace("#", "-")
|
username = username.replace("#", "-")
|
||||||
|
await self.bot.say("Looking up your profile information....")
|
||||||
url = base_url + "{}/stats/general".format(username)
|
url = base_url + "{}/stats/general".format(username)
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen(url)
|
urllib.request.urlopen(url)
|
||||||
|
@ -36,7 +38,7 @@ class Overwatch:
|
||||||
await self.bot.say("I have updated your saved battletag {}".format(ctx.message.author.mention))
|
await self.bot.say("I have updated your saved battletag {}".format(ctx.message.author.mention))
|
||||||
else:
|
else:
|
||||||
cursor.execute('insert into overwatch (id, battletag) values (%s, %s)', (ctx.message.author.id, username))
|
cursor.execute('insert into overwatch (id, battletag) values (%s, %s)', (ctx.message.author.id, username))
|
||||||
await self.bot.say("I have just saved your battletag {}".format(ctx.message.author.id))
|
await self.bot.say("I have just saved your battletag {}".format(ctx.message.author.mention))
|
||||||
config.closeConnection()
|
config.closeConnection()
|
||||||
|
|
||||||
@ow.command(pass_context=True, name="delete", aliases=['remove'])
|
@ow.command(pass_context=True, name="delete", aliases=['remove'])
|
||||||
|
|
Loading…
Reference in a new issue