discord.js
discord.js copied to clipboard
Sending embed message with Webhook client gets rate limited and exits my app without any error/warning
Which package is this bug report for?
discord.js
Issue description
For loop on thousands of items, send items through webhook using EmbedBuilder and webhookclient.send(). After 30 (I guess rate limit?), the app exits/stops without entering in any kind of warning or error state.
Code sample
I have a loop that calls this code over 1000 items, after ~30 messages correctly sent, my script just exits without any error. Even with the try/catch, the loops just breaks
//items.length = 1000;
//my script exits after 30, no error nothing
for (const item of items) {
const saleMessage = new EmbedBuilder()
.setColor(color)
.setTitle(title)
.setURL(link)
.setAuthor({ name: authorName, iconURL: authorIcon, url: authorLink })
.setDescription(description)
.addFields(fields)
.setTimestamp(date);
logger.info('sending msg');
try {
await webhookClient.send({
embeds: [saleMessage]
});
}catch(err) {
console.log(err);
}
}
### Package version
14.3.0
### Node.js version
16.13.1
### Operating system
_No response_
### Priority this issue should have
Medium (should be fixed soon)
### Which partials do you have configured?
No Partials
### Which gateway intents are you subscribing to?
Guilds
### I have tested this issue on a development release
_No response_
Are you listening to the "debug"
event? In my experience rate limits are logged through that.
Are you listening to the
"debug"
event? In my experience rate limits are logged through that.
In v14, iirc, RateLimits can be listened through <Client>.rest.on('rateLimited')
I'm listening to debug and rateLimited, there seem to be some websocket connection issue and the app just stops/crashes without any further log
#8779 should fix this