Closed kettle-7 closed 1 year ago
Worth adding, it must be something very specific in the code if nobody else has reported it
From a first (and quick) glance, it seems your issue is most likely caused because you recreate WebhookClient
s over and over, those extend BaseClient
which holds the REST manager (and its queue).
By recreating the queues all the time, you lose the information from previous ones, and as such, you're not queueing, but bursting single-request queues, that's why you get so many 429 and why you eventually get CF banned.
Try to reuse them, and likely then you will stop getting ratelimited.
From a first (and quick) glance, it seems your issue is most likely caused because you recreate
WebhookClient
s over and over, those extendBaseClient
which holds the REST manager (and its queue).By recreating the queues all the time, you lose the information from previous ones, and as such, you're not queueing, but bursting single-request queues, that's why you get so many 429 and why you eventually get CF banned.
Try to reuse them, and likely then you will stop getting ratelimited.
ahh right, i need to find a better way to store them (i had an object with an entry for each url but the garbage collector seemed to be cleaning them up too soon)
How the fuck do I stop these emails every 10 minutes
On Sun, 1 Jan 2023 at 11:31 AM, upside-down guy @.***> wrote:
From a first (and quick) glance, it seems your issue is most likely caused because you recreate WebhookClients over and over, those extend BaseClient which holds the REST manager (and its queue).
By recreating the queues all the time, you lose the information from previous ones, and as such, you're not queueing, but bursting single-request queues, that's why you get so many 429 and why you eventually get CF banned.
Try to reuse them, and likely then you will stop getting ratelimited.
ahh right, i need to find a better way to store them (i had an object with an entry for each url but the garbage collector seemed to be cleaning them up too soon)
— Reply to this email directly, view it on GitHub https://github.com/discordjs/discord.js/issues/8999#issuecomment-1368288152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVIZ6JB3PUAR3KDU7CNAQDLWQCX3HANCNFSM6AAAAAATNPEDQU . You are receiving this because you are subscribed to this thread.Message ID: @.***>
You can have a Map at the top level, or use Collection
from discord.js so you can call ensure, that way you can get or insert the WebhookClient.
Just don't recreate the cache every time it's called and you're fine.
How the fuck do I stop these emails every 10 minutes … On Sun, 1 Jan 2023 at 11:31 AM, upside-down guy @.> wrote: From a first (and quick) glance, it seems your issue is most likely caused because you recreate WebhookClients over and over, those extend BaseClient which holds the REST manager (and its queue). By recreating the queues all the time, you lose the information from previous ones, and as such, you're not queueing, but bursting single-request queues, that's why you get so many 429 and why you eventually get CF banned. Try to reuse them, and likely then you will stop getting ratelimited. ahh right, i need to find a better way to store them (i had an object with an entry for each url but the garbage collector seemed to be cleaning them up too soon) — Reply to this email directly, view it on GitHub <#8999 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVIZ6JB3PUAR3KDU7CNAQDLWQCX3HANCNFSM6AAAAAATNPEDQU . You are receiving this because you are subscribed to this thread.Message ID: @.>
Go to the home page of the repository, click Unwatch and then either Participating / Mentioned or Never
I'm confused why that message sent twice
You can have a Map at the top level, or use
Collection
from discord.js so you can call ensure, that way you can get or insert the WebhookClient.Just don't recreate the cache every time it's called and you're fine.
Yeah originally I did it like that and the objects inside the map became all null so I made the map a property of the Client
object and it works perfectly now. Thanks for the help !
Which package is this bug report for?
discord.js
Issue description
I can't really get a minimum reproducible example because I spent all of today trying to slim the code down and fix the issue but to no avail. I have a fairly big (but not huge) bot to link a Discord server to a modded Minecraft server's chat. Originally I was getting request time-out errors even after extending the timeout to a minute in the Client options, so I removed a lot of the messages getting sent and am now getting the Cloudflare block, I've had it three times now today and can't use Discord until probably tomorrow. I would prefer to avoid too much trial and error because I hear you can get a permanent ban. Anywho, during normal operations the bot stops sending messages (although it appears to continue functioning as usual) and on my laptop and phone I become unable to use Discord anything. The bot isn't used very much and I don't see how it manages to send enough requests to trigger the rate limit, and even if it does I'm pretty sure discord.js is supposed to handle the event. So the issue seems to lie in either Discord itself (in which case I can create a support ticket) or in discord.js. Again, example is not very minimal because I can't really test without risking permanently getting blocked from Discord which is something I would rather didn't happen.
Code sample
Package version
14.7.1
Node.js version
19.0.1
Operating system
Windows 11 22H2
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, GuildMembers, GuildMessages, MessageContent
I have tested this issue on a development release
No response