【问题标题】:HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty messageHTTPException:400 错误请求(错误代码:50006):无法发送空消息
【发布时间】:2021-08-24 04:04:36
【问题描述】:
@bot.command()
async def ping(ctx):
        embed=discord.Embed(title="",description="`Bot Latency...`",color=colour)
        msg = await ctx.send(embed=embed)
        times = []
        counter = 0
        embed = discord.Embed(title="More Information:", description="4 pings have been made and here are the results:", colour=colour)
        for _ in range(3):
            counter += 1
            start = time.perf_counter()
            embed.description=f"Trying Ping... {counter}/3"
            await msg.edit(embed=embed)
            end = time.perf_counter()
            speed = round((end - start) * 1000)
            times.append(speed)
            if speed < 160:
                embed.add_field(name=f"Ping {counter}:", value=f"???? | {speed}ms", inline=True)
            elif speed > 170:
                embed.add_field(name=f"Ping {counter}:", value=f"???? | {speed}ms", inline=True)
            else:
                embed.add_field(name=f"Ping {counter}:", value=f"???? | {speed}ms", inline=True)
        embed.set_author(name="????    PONG    ????", icon_url="https://img.icons8.com/ultraviolet/40/000000/table-tennis.png")
        embed.add_field(name="Bot Latency", value=f"{round(bot.latency * 1000)}ms", inline=True)
        embed.add_field(name="Normal Speed", value=f"{round((round(sum(times)) + round(bot.latency * 1000))/4)}ms")
        embed.set_footer(text=f"Total estimated elapsed time: {round(sum(times))}ms")
        await msg.edit(content=f":ping_pong: **{round((round(sum(times)) + round(bot.latency * 1000))/4)}ms**", embed=embed)

错误:命令引发异常:HTTPException:400 错误请求(错误代码:50006):无法发送空消息

几天前它还在工作,但突然停止工作 有什么帮助吗?

【问题讨论】:

    标签: python php discord.py


    【解决方案1】:

    color 嵌入错误。

    您可以使用类似color=discord.Color.light_gray()color=discord.Color.random() 的内容。

    请记住,每个嵌入都会采用随机颜色,如果您不希望这样,请在开始时将其保存到变量中并使用它

    Full list of colors

    【讨论】:

    • 我实际上有一个颜色变量
    • 那在哪里?我看不到它
    • colour = int("{:06x}".format(random.randint(0, 0xFFFFFF)), 16)
    • 你可以使用discord.Colour.random(),我编辑了我的代码来使用它。
    • 我的所有命令中的错误都不是那个
    猜你喜欢
    • 2021-10-06
    • 2020-11-05
    • 2015-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    相关资源
    最近更新 更多