Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ety
- from discord.ext import commands
- import discord
- from wiktionaryparser import WiktionaryParser
- parser = WiktionaryParser()
- class test:
- def __init__(self, bot):
- self.bot = bot
- @commands.command()
- async def ety(self, ctx, *, word: str=None):
- new_string = ''
- if ety.tree(word):
- description = parser.fetch(word)
- new_string += f"**Description** \n"
- new_string += f"{description[0]['etymology']} \n\n"
- new_string += f"**Pronunciations** \n"
- pronouncation = description[0]['pronunciations']['text']
- if pronouncation == []:
- pronouncation = 'None Found'
- new_string += f"{pronouncation} \n \n"
- new_string += f"**Related** \n"
- the_list = 'None found'
- if not description[0]['definitions']:
- the_list = 'None found'
- else:
- for item in description[0]['definitions'][0]['relatedWords']:
- print(item)
- if item['relationshipType'] == 'synonyms' or item['relationshipType'] == 'hyponyms':
- the_list = item['words']
- the_list = f"{', '.join(the_list)}."
- new_string += f"{the_list}. \n\n"
- new_string += f"**Tree** \n"
- new_string += f"{ety.tree(word)}"
- e = discord.Embed(colour=discord.Colour(0x278d89), description=f'{new_string}')
- await ctx.send(embed=e)
- else:
- e = discord.Embed(colour=discord.Colour(0xff0000), description=f'Nothing found!')
- await ctx.send(embed=e)
- def setup(bot):
- bot.add_cog(test(bot))
Add Comment
Please, Sign In to add comment