Fixing define method
This commit is contained in:
parent
e770e9cd72
commit
3ecc31e8e9
@ -121,14 +121,17 @@ async def on_message(message):
|
|||||||
print('fuck u')
|
print('fuck u')
|
||||||
|
|
||||||
if message.content.startswith('!define'):
|
if message.content.startswith('!define'):
|
||||||
word = message.content.split()[1:]
|
if len(message.content.split()) > 1:
|
||||||
try:
|
word = message.content.split()[1:]
|
||||||
definition = requests.get(
|
try:
|
||||||
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
definition = requests.get(
|
||||||
).json()['list'][0]['definition']
|
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
||||||
except IndexError:
|
).json()['list'][0]['definition']
|
||||||
definition = 'No definition found'
|
except IndexError:
|
||||||
await client.send_message(message.channel, "`{}`\n```{}```".format(' '.join(word), definition))
|
definition = 'No definition found'
|
||||||
|
await client.send_message(message.channel, "`{}`\n```{}```".format(' '.join(word), definition))
|
||||||
|
else:
|
||||||
|
await client.send_message(message.channel, help_methods.get_help_message('define'))
|
||||||
|
|
||||||
if message.content.startswith('!help'):
|
if message.content.startswith('!help'):
|
||||||
if len(message.content.split()) > 1:
|
if len(message.content.split()) > 1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user