discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

Sending embed message with Webhook client gets rate limited and exits my app without any error/warning

Open HRK44 opened this issue 1 year ago • 1 comments

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_

HRK44 avatar Sep 14 '22 23:09 HRK44

Are you listening to the "debug" event? In my experience rate limits are logged through that.

RedGuy12 avatar Sep 22 '22 14:09 RedGuy12

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')

JPBM135 avatar Sep 25 '22 11:09 JPBM135

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

HRK44 avatar Oct 20 '22 00:10 HRK44

#8779 should fix this

hackermondev avatar Oct 22 '22 19:10 hackermondev