Editing a message gets slower with time

Hello, i'm currently making a discord bot. Basically, all the bot needs to do is to edit a message every 1.1 second (to not get rate limited ). The problem with that is : The first hour, the requests my bot's sending to discord takes approximately 200 ms but past this first hour or so the requests gets slower (between 5 and 6 seconds)
21 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Nooxico
Nooxico9mo ago
discord.js@14.13.0 v18.16.0
ShompiFlen
ShompiFlen9mo ago
you are getting rate limited, i dont know from where did you get that editing messages with 1.1 seconds of delay will help you avoid rate limits
Nooxico
Nooxico9mo ago
do you have a detailed explanation of what the rate limit is?? i can't find it From what i understand, the bot can send 5 request every 5 seconds
ShompiFlen
ShompiFlen9mo ago
rate limits are not public information and they are also dynamic
d.js docs
d.js docs9mo ago
Ratelimits are dynamically assigned by the API based on current load and may change at any point. - The scale from okay to API-spam is sliding and depends heavily on the action you are taking - Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
Nooxico
Nooxico9mo ago
I've got logs, and there's not any warnings about rate limit
ShompiFlen
ShompiFlen9mo ago
where do you have logs try this
d.js docs
d.js docs9mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
ShompiFlen
ShompiFlen9mo ago
whenever your bot slows down editing messages check the console and see what it shows
Nooxico
Nooxico9mo ago
that's what i do to get logs :
client.rest.on("rateLimited", (r) => {
console.log(r)
})
client.rest.on("rateLimited", (r) => {
console.log(r)
})
im gonna try I used to have a "rate limited" warn. But with the 1.1 second delay i don't have it anymore
ShompiFlen
ShompiFlen9mo ago
the 5 - 6 second delay you describe does sound like a ratelimit on the channel messages endpoint
Nooxico
Nooxico9mo ago
it does, but the warn doesn't show up in my logs that's my problem, i can't fix the problem if i don't know what it is xD Do you know where i can find rate limit for each endpoint?
ShompiFlen
ShompiFlen9mo ago
i just told you that ratelimits are not public information
Nooxico
Nooxico9mo ago
ok gotchu sorry
ShompiFlen
ShompiFlen9mo ago
debug it with the thing i suggested and see if that shows something
Nooxico
Nooxico9mo ago
forgot that u said that
ShompiFlen
ShompiFlen9mo ago
if it doesnt then its gonna be tricky i doubt is a library issue though but we will see
treble/luna
treble/luna9mo ago
its ratelimit
Nooxico
Nooxico9mo ago
OeDo 22/09/2023 16:31:04 > Update Controller message
OeDo> Updated message controller gui in 245ms
OeDo> Next call time 855ms
qFPt 22/09/2023 16:31:04 > Update Controller message
qFPt> Updated message controller gui in 235ms
qFPt> Next call time 865ms
ckCa 22/09/2023 16:31:05 > Update Controller message
ckCa> Updated message controller gui in 211ms
ckCa> Next call time 889ms
iRqG 22/09/2023 16:31:05 > Update Controller message
lH6V 22/09/2023 16:31:06 > Update Controller message
iRqG> Updated message controller gui in 4072ms
iRqG> Next call time 0ms
VrtY 22/09/2023 16:31:10 > Update Controller message
[WS => Shard 0] Heartbeat acknowledged, latency of 109ms.
lH6V> Updated message controller gui in 4167ms
lH6V> Next call time 0ms
7a8I 22/09/2023 16:31:10 > Update Controller message
VrtY> Updated message controller gui in 5290ms
VrtY> Next call time 0ms
rnkf 22/09/2023 16:31:15 > Update Controller message
7a8I> Updated message controller gui in 5132ms
7a8I> Next call time 0ms
E3fH 22/09/2023 16:31:16
OeDo 22/09/2023 16:31:04 > Update Controller message
OeDo> Updated message controller gui in 245ms
OeDo> Next call time 855ms
qFPt 22/09/2023 16:31:04 > Update Controller message
qFPt> Updated message controller gui in 235ms
qFPt> Next call time 865ms
ckCa 22/09/2023 16:31:05 > Update Controller message
ckCa> Updated message controller gui in 211ms
ckCa> Next call time 889ms
iRqG 22/09/2023 16:31:05 > Update Controller message
lH6V 22/09/2023 16:31:06 > Update Controller message
iRqG> Updated message controller gui in 4072ms
iRqG> Next call time 0ms
VrtY 22/09/2023 16:31:10 > Update Controller message
[WS => Shard 0] Heartbeat acknowledged, latency of 109ms.
lH6V> Updated message controller gui in 4167ms
lH6V> Next call time 0ms
7a8I 22/09/2023 16:31:10 > Update Controller message
VrtY> Updated message controller gui in 5290ms
VrtY> Next call time 0ms
rnkf 22/09/2023 16:31:15 > Update Controller message
7a8I> Updated message controller gui in 5132ms
7a8I> Next call time 0ms
E3fH 22/09/2023 16:31:16
here are my logs after an hour so everything works perfectly fine for 1 hour, but past that, it takes longer to send a request was ratelimit in discord js 13 but now it's ratelimited
ShompiFlen
ShompiFlen9mo ago
this doesnt look like the logs from debug or warn these are your logs, this doesnt help hmm... it is weird though i do see the heartbeat in your logs so uh i guess it is logging debug events, weird that the ratelimit is not showing there... unless its not supposed to, im not entirely sure on this one :/