【问题标题】:Discord.py embed not getting sentDiscord.py 嵌入未发送
【发布时间】:2021-02-05 01:28:55
【问题描述】:

我只是用 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)

但是,嵌入不会发布。我试图找到错误,但我找不到。有人可以帮帮我吗?

谢谢!

【问题讨论】:

    标签: python discord discord.py embed


    【解决方案1】:

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

    以下是修改后的代码:

    @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)
    

    【讨论】:

      猜你喜欢
      • 2021-02-13
      • 2021-10-20
      • 2020-07-28
      • 2020-05-31
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      相关资源
      最近更新 更多