make the defintion an embed
This commit is contained in:
parent
4059240816
commit
56c86b9f90
@ -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):
|
||||
|
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user