我正在discord.py中创建一个机器人,遵循教程(here) 我的代码工作正常,直到这里命令描述如下: `
@bot.command()
async def commands(ctx : commands.Context) -> discord.Message:
但这一次是这部分:
bot.command(name="avatar")
async def send_avatar(ctx : commands.Context, user : discord.User = None) -> discord.Message:
print("avatar command")
if user is None :
user = ctx.author
embed = discord.Embed(
title = f"{user.name}'s profile picture",
description=f"[Lien]({user.display_avatar.url})",
color = discord.Color.red()
)
embed.set_image(url =user.display_avatar.url)
return await ctx.send(embed=embed)
我提出了这个错误:
AttributeError: 'Command' object has no attribute 'Context'
,但在这一行上完全正确,没有其他错误(我有 6 个其他命令可以使用相同的定义正常工作)
这就是命令具有 Context 属性的要点吗?要么我对一个明显的错误完全视而不见,要么我完全迷失了。
从discord.py不和谐服务器得到答案^^ 该错误是因为我的
commands
命令之前已经在discord.py 中使用了一个名称
那是我的错,问题解决了