我试图为我正在开发的机器人制作一个帮助嵌入页面。然而,它没有嵌入,而是显示了这些乱码:
我使用的代码:
@client.command
async def help(ctx):
print("ctx.message.author.avatar_url")
embed=discord.Embed(title="Commands", description="Help Page", color=0xad1f1f)
embed.set_author(name=ctx.message.author.name + "#" + ctx.message.author.discriminator, icon_url=ctx.message.author.avatar_url)
embed.add_field(name=".help", value="Shows this page. Do .help [Page] for more help pages", inline=False)
embed.add_field(name=".say", value="Says what you input and removes your message. (Administrator Exclusive)", inline=False)
embed.add_field(name=".avatar", value="Sends your avatar. Or the avatar of anyone mentioned or replied to.", inline=False)
embed.set_footer(text="Page (1/1)")
await ctx.message.reply(embed=embed)
我已经尝试了一切。我已经用谷歌搜索过,打印了所有变量,以防
avatar_url
出现问题。我现在已经厌倦了。也许这是一个语法错误,我真的很愚蠢,我希望情况并非如此。
这是discord.py 的默认帮助命令。在定义你的机器人后立即添加来禁用它:
例如:
client = commands.Bot(command_prefix="$", case_insensitive=True)
client.remove_command('help')
根据docs禁用帮助命令的正确方法是将
help_command=None
传递到discord.ext.commands.Bot
的构造函数中,例如:
bot = commands.Bot(help_command=None)