#Rate Limit Queue Ordering & Invalid Request Message

1 messages · Page 1 of 1 (latest)

mental storm
#

Is it possible to ensure requests will be processed first in first out (by bucketId?) with Discordeno? Should it do this out of the box already and preserve ordering?

Specifically I am looking to have a single-server (custom) bot that adds reactions in a specific order to a message, while trying to avoid having my own buckets handling global and reaction rate limits..

I've noticed if I just fire off a bunch of bot.helpers.addReaction it (appears to) randomly deciding to do a different one first. I thought it may be related to the rate limit resetting as soon as that request is sent but before the previously rate limited reaction is processed from queue. Assuming that is intended, and it happens quite rarely. It also spams invalid requests which I thought DD would handle the rate limit to prevent those, unless I am just misunderstanding the error.

This server gets bursts of messages so I frequently have to queue for the reaction adding rate limit and just looking for the best way to handle this across the bot.

Wasn't sure if there was much to any customization capability for the pre-built implementation or not. Otherwise was wondering if this is something I need nirn proxy for potentially. Its a custom bot so didn't really want to have to run it as well.

mental storm
#

Rate Limit Queue Ordering & Invalid Request Message

soft timber
#

also when you say you fire off a bunch of addReaction, what are you doing exactly? and are you awaiting them?

mental storm
# soft timber they should be sent to discord in the order the proxy receives them except if on...

Ah ok, maybe that is what it is. It might be failing then when it happens and going back of queue. I didn't think about that. It is almost always in order so that would be a reasonable assumption.

During a async messageCreate handler, I await the bot.helpers.addReaction to the channel and message from the event. If I get like 10 messages at once, it eventually does (usually) add them all in the same order but I get ~160 invalid requests while it is working on adding them all. It appears to be an automatic retry
[8/5/2025 12:46:25 PM] WARN Discordeno > [InvalidBucket] an invalid request was made. Increasing invalidRequests count to 161

async (message) => {
      // add 5 shape reactions to the message
      await DiscordMod.client.helpers.addReaction(message.channelId, message.id, '🟢');
      await DiscordMod.client.helpers.addReaction(message.channelId, message.id, '🔵');
      await DiscordMod.client.helpers.addReaction(message.channelId, message.id, '🟡');
      await DiscordMod.client.helpers.addReaction(message.channelId, message.id, '🟣');
      await DiscordMod.client.helpers.addReaction(message.channelId, message.id, '🔴');
    }

(in essence what I am doing, but with more logic and the such on if and when it should react)

Debug logging shows it getting rate limited over and over:

#
[8/5/2025 3:40:17 AM] DEBUG Discordeno > Queue Bot /channels/1396824837028319355/messages/1402134079792484392/reactions/reactions process pending while loop ran with 1.
[8/5/2025 3:40:17 AM] DEBUG Discordeno > sending request to https://discord.com/api/v10/channels/1396824837028319355/messages/1402134079792484392/reactions/%E2%9D%A4%EF%B8%8F/@me with payload: {
  body: undefined,
  headers: {
    "user-agent": "DiscordBot (https://github.com/discordeno/discordeno, v21.0.0)",
    authorization: "Bot tokenhere"
  },
  method: "PUT"
}
[8/5/2025 3:40:17 AM] DEBUG Discordeno > request fetched from https://discord.com/api/v10/channels/1396824837028319355/messages/1402134079792484392/reactions/%E2%9D%A4%EF%B8%8F/@me with status 429 & Too Many Requests
[8/5/2025 3:40:17 AM] WARN Discordeno > [InvalidBucket] an invalid request was made. Increasing invalidRequests count to 2
[8/5/2025 3:40:17 AM] DEBUG Discordeno > Request to https://discord.com/api/v10/channels/1396824837028319355/messages/1402134079792484392/reactions/%E2%9D%A4%EF%B8%8F/@me failed.
[8/5/2025 3:40:17 AM] DEBUG Discordeno > Request to https://discord.com/api/v10/channels/1396824837028319355/messages/1402134079792484392/reactions/%E2%9D%A4%EF%B8%8F/@me was ratelimited.
soft timber
#

i find it a bit strange you are also getting invalid requests to be honest, because it should deal with the rate limits

but also emojis have a bit of a strange rate limits and I don't remember if that extends to reactions as well

mental storm
#

My understanding was its 4/1s/per channel. I just wasn't sure why I was getting the invalid requests, but just those 5 awaits and me sending 10 test messages will spam invalid requests on latest @next release.

I am using Deno but I am not sure if that has any impact on that regard.

soft timber
#

i will try to see if there is some bug in discordeno about this later/tomorrow

mental storm
#

Ty. 🙂

soft timber
#

ok with a bit of spamming (like 6 messages...) and the 5 reactions i can repro this, so now i get to check whats going on with the ratelimit

soft timber
#

if the ratelimit is per channel then the issue is that at the moment we do create queues for each message

soft timber
#

ok so i'm having a lot of fun (no) with reading both docs and djs & dpy ratelimit for reference

and while fixing this specific bug is somewhat simple (replace the message id with something else)

  • we do not handle the fact that messages older than 2 weeks have special rules on ratelimit (which btw greats docs, documented in an obscure issue on the discord-api-docs repo)
  • we do not really get the major parameter the ratelimit is based on
  • we do not really take into account the HTTP method expect in one case for some reason (deleting messages)
soft timber
mental storm
leaden gull
soft timber
#

Bot for the multi auth, everything else for the guess on the bucket

soft timber
#

also: it doesn't tell you how long a bucket lasts, you get to guess that as well

leaden gull
soft timber
mental storm
#

Let me enable node_modules real quick to test that on my project and I'll touch back in a moment.

soft timber
mental storm
#

Yes

soft timber
#

oh ok, i still find it strage that they don't use node_modules in some cases

#

ig i'm just used to node

mental storm
#

It just puts it in a global cache instead of per-project and uses a lock file to version control it.

#

I just don't like to override my global one so I don't make it mad lol

mental storm
#

Much appreicated on the fix ❤️

soft timber