Guest User

Untitled

a guest
Nov 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. import ety
  2. from discord.ext import commands
  3. import discord
  4. from wiktionaryparser import WiktionaryParser
  5. parser = WiktionaryParser()
  6.  
  7. class test:
  8. def __init__(self, bot):
  9. self.bot = bot
  10.  
  11. @commands.command()
  12. async def ety(self, ctx, *, word: str=None):
  13. new_string = ''
  14. if ety.tree(word):
  15. description = parser.fetch(word)
  16. new_string += f"**Description** \n"
  17. new_string += f"{description[0]['etymology']} \n\n"
  18. new_string += f"**Pronunciations** \n"
  19. pronouncation = description[0]['pronunciations']['text']
  20. if pronouncation == []:
  21. pronouncation = 'None Found'
  22. new_string += f"{pronouncation} \n \n"
  23. new_string += f"**Related** \n"
  24. the_list = 'None found'
  25. if not description[0]['definitions']:
  26. the_list = 'None found'
  27. else:
  28. for item in description[0]['definitions'][0]['relatedWords']:
  29. print(item)
  30. if item['relationshipType'] == 'synonyms' or item['relationshipType'] == 'hyponyms':
  31. the_list = item['words']
  32. the_list = f"{', '.join(the_list)}."
  33.  
  34. new_string += f"{the_list}. \n\n"
  35. new_string += f"**Tree** \n"
  36. new_string += f"{ety.tree(word)}"
  37. e = discord.Embed(colour=discord.Colour(0x278d89), description=f'{new_string}')
  38. await ctx.send(embed=e)
  39. else:
  40. e = discord.Embed(colour=discord.Colour(0xff0000), description=f'Nothing found!')
  41. await ctx.send(embed=e)
  42.  
  43.  
  44.  
  45. def setup(bot):
  46. bot.add_cog(test(bot))
Add Comment
Please, Sign In to add comment