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):
|
async def define(ctx):
|
||||||
|
|
||||||
import define_word
|
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')
|
@bot.command(name='greentext')
|
||||||
async def greentext(ctx):
|
async def greentext(ctx):
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import requests
|
import requests
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
|
import discord
|
||||||
|
|
||||||
|
|
||||||
def get_definition(content):
|
def get_definition(content):
|
||||||
"""
|
"""
|
||||||
get_definition(content)
|
get_definition(content)
|
||||||
@ -13,6 +16,7 @@ def get_definition(content):
|
|||||||
definition = requests.get(
|
definition = requests.get(
|
||||||
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
||||||
).json()['list'][0]['definition']
|
).json()['list'][0]['definition']
|
||||||
|
site = 'Urban Dictionary'
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
try:
|
try:
|
||||||
@ -20,9 +24,14 @@ def get_definition(content):
|
|||||||
definition = requests.get(
|
definition = requests.get(
|
||||||
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format('%20'.join(word))
|
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format('%20'.join(word))
|
||||||
).json()['results'][0]['senses'][0]['definition'][0]
|
).json()['results'][0]['senses'][0]['definition'][0]
|
||||||
|
|
||||||
|
site = 'Pearson'
|
||||||
except IndexError:
|
except IndexError:
|
||||||
definition = 'No definition found'
|
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')
|
return help_methods.get_help_message('define')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user