[英]Inconsistent behavior when sending messages to a large amount of webhooks
一次向大量 webhook 发送消息时,我得到的结果非常不一致。
webhooklist.forEach(webhook => {
var row = new MessageActionRow()
.addComponents(
savebutton,
reportbutton
)
webhook.send({content: url, components: [row]}).catch(err => {
if (err instanceof DiscordAPIError) {
if (err.code === 10015) {
//remove the webhook from the database
db.prepare('DELETE FROM webhooks WHERE webhookID = ?').run(webhook.id);
console.log(`Removed webhook ${webhook.id}`);
} else {
console.log(err);
}
} else {
console.log(err);
}
});
});
70% 的时间它可以正常工作,但有时所有请求都会超时并用 http 错误淹没控制台,而且几乎总是会多次发送消息。 (大约有 1500 个公会,每个公会都有一个 webhook)
拥有错误堆栈会很有用——无论如何,最有可能的是你受到速率限制——使用 Discord API 同时发送 1500 条消息很多
我建议您将每个 webhook 的请求延迟 10 秒或更长时间,这可以通过 setTimeout 来完成
下次在问题中包含错误堆栈; 所以更容易解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.