Pycord on_connect() 中的 400 错误请求
因此,我最近将我的机器人移植到了 Slash Commands,因为现在这是一件事,但每当我运行它时,它都会抛出 discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
。当我运行任何命令时都会发生同样的情况。
代码位于此处。
on_connect() 和命令的完整错误跟踪位于此处。
有些人说这是因为他们的消息太大,但我什至没有发送消息。一旦我执行机器人,就会抛出错误。
So, I recently ported my bot to Slash Commands, since that's a thing now, but whenever I run it it throws discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
. Same happens when I run any command.
The code is here.
The full error trace of both on_connect() and the commands are here.
Some people says it's because their message is too large, but I'm not even sending a message. The error gets thrown as soon as I execute the bot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题基本上在于错误消息本身:
必需的参数之前不能有可选参数,一些命令就是这种情况,例如
mute
。通过使用默认值 (False
) 定义参数silent
,可以将其设为可选,但随后添加另一个参数reason
,该参数不是可选的,这是不和谐所不允许的。要解决此问题,您可以通过删除=False
使silent
成为必需参数The problem is basically in the error message itself:
You can't have optional arguments before required arguments, which is the case in a few of your commands, for example
mute
. By defining the argumentsilent
with a default value (False
) you make it optional, but then you add another argumentreason
, which isn't optional, which isn't allowed by discord. To fix this, you can makesilent
a required argument, by removing=False