Untitled
unknown
plain_text
2 years ago
645 B
6
Indexable
rom PyDictionary import PyDictionary
dictionary = PyDictionary()
async def get_dictionary_definition(interaction, word):
definition = dictionary.meaning(word)
if definition:
formatted_definition = '\n'.join([f'**{key}**: {", ".join(val)}' for key, val in definition.items()])
try:
await interaction.response.send_message(content=f"Definition of '{word}':\n{formatted_definition}")
except discord.errors.NotFound:
print("Interaction not found. It may have expired.")
else:
await interaction.response.send_message(content=f"Sorry, I could not find a definition for '{word}'.")
Editor is loading...
Leave a Comment