From 3ecc31e8e9fd6dcafe37e38b8d4809f73eb2bcf5 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Wed, 9 Aug 2017 12:24:44 -0700 Subject: [PATCH] Fixing define method --- app/dragon-bot.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index ca28d18f..c9f3d242 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -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'): if len(message.content.split()) > 1: