Merged in fix_define (pull request #14)

Fixing define method, fixes #5
This commit is contained in:
Luke Robles 2017-08-09 21:03:19 +00:00
commit 5b8d183db9

View File

@ -121,14 +121,17 @@ async def on_message(message):
print('fuck u')
if message.content.startswith('!define'):
word = message.content.split()[1:]
try:
definition = requests.get(
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
).json()['list'][0]['definition']
except IndexError:
definition = 'No definition found'
await client.send_message(message.channel, "`{}`\n```{}```".format(' '.join(word), definition))
if len(message.content.split()) > 1:
word = message.content.split()[1:]
try:
definition = requests.get(
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
).json()['list'][0]['definition']
except IndexError:
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'):
help_message = help_methods.parse_message(message.content)