Nextcord嵌入消息命令能否设置多个触发别名?附YouTube命令报错问题
问题修复方案
错误原因
你的代码触发错误的核心原因是:命令主名称与别名配置重复,你将youtube同时设置为命令主函数名,又加入了aliases别名列表,导致Nextcord注册命令时出现命名冲突。aliases参数的作用是配置除主命令名以外的额外触发词,不需要将主命令名本身加入列表。
修复后代码
@client.command(aliases=['yt']) async def youtube (ctx): embed = nextcord.Embed( title="Youtube", url="https://www.youtube.com/", description="Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.", colour = nextcord.Colour.brand_red(), ) await ctx.send(embed=embed)
修改完成后,你可以用你的机器人命令前缀加youtube或者yt两种方式触发该命令,正常发送YouTube嵌入消息。
内容的提问来源于stack exchange,提问作者BasicLol
相关产品推荐
相关产品推荐

