@commands.command(aliases=['lookup'])
async def define(self, message, *, arg):
dictionary=PyDictionary()
Define = dictionary.meaning(arg)
length = len(arg.split())
if length == 1:
embed = discord.Embed(description="**Noun:** " + Define["Noun"][0] + "\n\n**Verb:** " + Define["Verb"][0], color=0x00ff00)
embed.set_author(name = ('Defenition of the word: ' + arg),
icon_url=message.author.avatar_url)
await message.send(embed=embed)
else:
CommandError = discord.Embed(description= "A Term must be only a single word" , color=0xfc0328)
await message.channel.send(embed=CommandError)
我想检查词典Define
中是否有Noun
和Verb
,因为当一个单词只在其定义中有名词时,会抛出错误,因为我试图让机器人输出名词和动词,你能理解我的意思吗?我对词典不太熟悉,希望得到帮助。
if value in my_dict
的意思是:如果某个值在我的字典中。 - Prune