Discord Bot(JDA)速率限制

huangapple go评论99阅读模式
英文:

Discord Bot (JDA) Rate Limit

问题

我在某处读到过,每 10 分钟只能修改 2 个频道,但对于发送的消息是否也是如此?还是每 10 分钟只能执行两次类似于更改/发送/创建的操作?

另外,“.queue();”、“.complete();”和“.submit();”之间有什么区别呢?

提前感谢:D

英文:

I read somewhere that you can only modify 2 channels every 10 minuntes, but is this also the case with the messages that you send or can you only perform an operation like change / send / create twice every 10 min?

And what's the difference between .queue(); .complete(); and .submit();

Thanks in advance: D

答案1

得分: 2

速率限制会根据您执行的操作而变化。速率限制

对于.queue(), .complete(), .submit(),请查看文档此处(点#7)。

英文:

Rate limits change depending on the action you're performing. Rate Limits

For .queue(), .complete(), .submit() view the documentation here (Point #7).

答案2

得分: 1

速率限制通常指更改频道的名称/主题或创建/删除频道。
但是,限制也可以应用于添加反应,甚至发送消息,以防止滥用/垃圾信息(您还可以注意到在自己的Discord服务器中进行垃圾信息投递)。
根据Discord文档:“用于控制表情符号的路由不遵循正常的速率限制惯例。这些路由在每个服务器上特定地受限,以防止滥用。这意味着API返回的配额可能不准确,您可能会遇到429错误。”

如果您正在创建一个定期添加表情的机器人,您可能希望在这些操作之间设置一个小的超时时间,否则机器人将受到速率限制,并且只能在相当长的时间后才能恢复。

为了解决这个问题,我添加了一个布尔值,该值仅在完成添加最后一个表情的队列操作后才会被重置。这是一个取巧的方法,但可以解决问题。

英文:

Rate-limits usually refer to changing the name/topic of a channel, or creating/deleting channels.
But limits can be also applied for adding reactions or even sending messages, to prevent abuse/spam (you can also notice if you spam in your own discord server).
From the Discord documentation: "Routes for controlling emojis do not follow the normal rate limit conventions. These routes are specifically limited on a per-guild basis to prevent abuse. This means that the quota returned by our APIs may be inaccurate, and you may encounter 429s."

If you are creating a bot that adds emotes on a regular basis, you might want to set a small timeout between such actions, otherwise the bot will get rate limited and will only resume after a quite long period of time.

To solve this, I added a boolean that only gets reset after the queue action of adding the last emoji is complete. It's a hacky solve, but does the job.

huangapple
  • 本文由 发表于 2020年7月25日 18:48:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/63087400.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定