make the defintion an embed

This commit is contained in:
Luke Robles 2020-09-15 13:23:53 -07:00
parent f326f953ed
commit c62f322bbc
2 changed files with 11 additions and 2 deletions

View File

@ -207,7 +207,7 @@ async def dog(ctx):
async def define(ctx):
import define_word
await ctx.send(define_word.get_definition(ctx.message.content))
await ctx.send(embed=define_word.get_definition(ctx.message.content))
@bot.command(name='greentext')
async def greentext(ctx):

View File

@ -1,6 +1,9 @@
import requests
import help_methods
import discord
def get_definition(content):
"""
get_definition(content)
@ -13,6 +16,7 @@ def get_definition(content):
definition = requests.get(
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
).json()['list'][0]['definition']
site = 'Urban Dictionary'
except IndexError:
try:
@ -20,9 +24,14 @@ def get_definition(content):
definition = requests.get(
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format('%20'.join(word))
).json()['results'][0]['senses'][0]['definition'][0]
site = 'Pearson'
except IndexError:
definition = 'No definition found'
return "`{}`\n```{}```".format(' '.join(word), definition)
embed = discord.Embed(description="%s:\n%s" % (' '.join(word), definition), color=0x428bca, type="rich")
embed.set_author(name="From %s" % site)
return embed
return help_methods.get_help_message('define')