【问题标题】:discord.py - discord.errors.HTTPException: 400 Bad Request (error code: 50035): - even though message is under 2000 charactersdiscord.py - discord.errors.HTTPException: 400 Bad Request (error code: 50035): - 即使消息少于 2000 个字符
【发布时间】:2020-07-11 22:06:45
【问题描述】:
      msg = discord.Embed(
           title = country_name + ' Coronavirus cases',
           colour = discord.Colour.blue(),


           )
       msg.set_thumbnail(url='https://www.worldometers.info/img/flags/'+ country_code +'-flag.gif')
       msg.add_field(name='**Total Cases**', value = total_cases, inline = False)
       msg.add_field(name='**Deaths**', value = total_deaths, inline = False)
       msg.add_field(name='**Recovered**', value = total_recovered, inline = False)
       await message.channel.send(embed=msg)

错误:

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.1.value: This field is required

我收到了错误,查了一下,上面写着“当字符超过 2000 个时会发生这种情况”,我的消息少于 100 个。我的代码从网站抓取数据并通过在不和谐中嵌入消息。任何帮助或建议都会有所帮助。

【问题讨论】:

  • 错误是Invalid Form Bodydiscordapp.com/developers/docs/topics/…这与“超过2000个字符”无关。我怀疑您使用的是非常旧的 discord.py 库版本。请python -m pip freeze 告诉我们您的版本
  • `discord==1.0.1 discord.py==1.2.5
  • 卸载 discord==1.0.1 python -m pip uninstall discord 并重试
  • 我仍然遇到和以前一样的错误。
  • embed.fields.1.value: This field is required 确保该值为字符串。

标签: python discord.py


【解决方案1】:

我刚刚得到了同样的错误,我发现原因是你试图发送一个 NoneType 的嵌入。请务必检查值 total_cases、deaths 和 recoverys 是否只是空字符串

【讨论】:

    猜你喜欢
    • 2021-10-06
    • 2013-06-05
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2017-09-26
    • 2015-08-01
    • 2014-12-04
    • 2019-10-22
    相关资源
    最近更新 更多