Discord.py嵌入未发送

时间:2020-10-22 04:27:32

标签: python discord discord.py embed

我当时只是用discord.py编写一个机器人,但是我的帮助命令似乎出现了问题,因为出于某种原因,我希望发送的嵌入内容没有显示。

这是我的帮助命令代码:

@client.command(aliases=["h"])
async def bothelp(ctx):
   await ctx.send("help command coming soon!")
   embed = discord.Embed(title = "Help for the bot", description = "", color = discord.Colour.purple())
   embed.add_field(name = "Command List", value = "", inline = False)
   embed.add_field(name = "#hello", value = "Replies with a greeting. \nAliases: hey, hi", inline = True)
   embed.add_field(name = "#whois <mention>", value = "Gives the user info of the member mentioned. \nAliases: user, info", inline = True)
   embed.add_field(name = "#clear (number)", value = "Clears the number of messages given by the user. If number is not entered, deletes the most recent message. \nAliases = c \nPermissions = Manage Messages", inline = True)
   embed.add_field(name = "#kick (mention)", value = "Kicks the member mentioned. \nAliases: k \n Permissions: Kick Members", inline = True)
   embed.add_field(name = "#ban (mention)", value = "Bans the member mentioned. \nAliases: b \n Permissions: Ban Members", inline = True)
   embed.add_field(name = "#unban (username with tag)", value = "Unbans the member specified. \nAliases: ub \n Permissions: Ban Members", inline = True)
   embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
   await ctx.send(embed=embed)

但是,嵌入不会被发布。我尝试查找错误,但无法。有人可以帮我吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

字段值不能为None或为空字符串,您的第一个字段没有值。给它添加一些价值

下面是修改后的代码:

@client.command(aliases=["h"])
async def bothelp(ctx):
   await ctx.send("help command coming soon!")
   embed = discord.Embed(title = "Help for the bot", description = "", color = discord.Colour.purple())
   embed.add_field(name = "Command List", value = "Here are all commands", inline = False)
   embed.add_field(name = "#hello", value = "Replies with a greeting. \nAliases: hey, hi", inline = True)
   embed.add_field(name = "#whois <mention>", value = "Gives the user info of the member mentioned. \nAliases: user, info", inline = True)
   embed.add_field(name = "#clear (number)", value = "Clears the number of messages given by the user. If number is not entered, deletes the most recent message. \nAliases = c \nPermissions = Manage Messages", inline = True)
   embed.add_field(name = "#kick (mention)", value = "Kicks the member mentioned. \nAliases: k \n Permissions: Kick Members", inline = True)
   embed.add_field(name = "#ban (mention)", value = "Bans the member mentioned. \nAliases: b \n Permissions: Ban Members", inline = True)
   embed.add_field(name = "#unban (username with tag)", value = "Unbans the member specified. \nAliases: ub \n Permissions: Ban Members", inline = True)
   embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
   await ctx.send(embed=embed)