我可以安全地忽略这些错误吗? [英] Can I safely ignore these errors?

查看:84
本文介绍了我可以安全地忽略这些错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@client.event
async def on_message_edit(before, after):
    channel = client.get_channel (649024513614282764)
    embed=discord.Embed(title="Edited Message", description=f"Message sent by {before.author.mention} ({before.author}) in {before.channel.mention}", color=0xffff00, timestamp=datetime.datetime.now())
    embed.add_field(name=f"{before.content}", value=f"{after.content}", inline=False)
    if channel is None:
        print("Channel not found")
    else:
        await channel.send(embed=embed)

运行上面的命令时,它已按预期运行。

When I run the above, it's running as intended. However it's chucking

Exception has occurred: HTTPException
400 BAD REQUEST (error code: 50035): Invalid Form Body
In embed.fields.0.name: This field is required
In embed.fields.0.value: This field is required

由于它可以正常工作,我现在暂时忽略这些错误。这会引起进一步的问题吗?如果是这样,我该如何解决?谢谢。

I'm ignoring the errors for now, since it's working. Will this cause an issue further down the line? If so, how can I fix it? Thank you.

推荐答案

您的嵌入内容未发送,因为 before.content after.content 是空字符串。

因此,该错误告诉您这些字段是必需的。

消息

您可以通过简单地检查 before.content 和<$是否存在来处理此问题。 c $ c> after.content ,然后将字段添加到嵌入中。

Your embed isn't being sent because before.content and after.content are empty strings.
Hence the error telling you that those fields are required.
The message in question is likely from a bot and only has an embed.
You can handle this by simply checking for the existence of before.content and after.content before you add the field to the embed.

这篇关于我可以安全地忽略这些错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆