mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 12:18:54 -05:00
!urban async friendly
This commit is contained in:
parent
33f5114666
commit
2a073bbd50
5
red.py
5
red.py
@ -820,11 +820,12 @@ async def urban(message):
|
|||||||
msg.remove(msg[0])
|
msg.remove(msg[0])
|
||||||
msg = "+".join(msg)
|
msg = "+".join(msg)
|
||||||
search = "http://api.urbandictionary.com/v0/define?term=" + msg
|
search = "http://api.urbandictionary.com/v0/define?term=" + msg
|
||||||
result = requests.get(search).json()
|
async with aiohttp.get(search) as r:
|
||||||
|
result = await r.json()
|
||||||
if result["list"] != []:
|
if result["list"] != []:
|
||||||
definition = result['list'][0]['definition']
|
definition = result['list'][0]['definition']
|
||||||
example = result['list'][0]['example']
|
example = result['list'][0]['example']
|
||||||
await client.send_message(message.channel, "Definition: " + definition + "\n\n" + "Beispiel: " + example )
|
await client.send_message(message.channel, "Definition: " + definition + "\n\n" + "Example: " + example )
|
||||||
else:
|
else:
|
||||||
await client.send_message(message.channel, "Your search terms gave no results.")
|
await client.send_message(message.channel, "Your search terms gave no results.")
|
||||||
except:
|
except:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user