deferReply not working on specific server

Hello. We are running a small hosting service for Discord bots but one of our servers can't execute editReply from DIscord.js. Discord.py works just fine. The bots just stay on "is thinking..." until that eventually times out. After around 35 minutes the console shows an API error "Invalid Webhook Token". The weird thing is that everything else works fine and as I said, with Python bots it works as well. It's just the editReply function on this one particular server. Does anyone have an idea what the issue might be or how to solve this?
6 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
MrMythical
MrMythical2y ago
This sounds very much like a rate limit
ncls.
ncls.OP2y ago
It's not a rate limit. Everything works despite this one single function. And it works in Python
d.js docs
d.js docs2y 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
MrMythical
MrMythical2y ago
Use this
ncls.
ncls.OP2y ago
I already did. No output What versions would be outdated? I don't think that's the issue. I freshly created the test bot, so NPM probably downloaded LTS and all the bots that don't work on this server, work on the other ones or on the people's local machines. Ok, but in that case it still doesn't work with up to date bots. And as I already said, the bots that can't execute editReply on this one server, can execute it everywhere else. Be it another server or locally on the people's pc No, it's just a Docker container. All servers have the same Docker images. Hmm. But then why would just one specific function not work and throw an "Invalid Webhook Token" API error, while Python works just fine doing the exact same thing? We are facing this issue since months and we have no idea what the issue could be. Both servers are running the exact same Docker images, so the bots are basically running in the exact same enviroment on both servers. Also normal webhooks work just fine on the server. So it does at least have something to do with Discord.js and since I don't know enough about the implementation of Djs itself, I thought I'd ask here so that someone maybe has an idea what could be the issue. Both return version 14.11.0, no rate limit errors occur It didn't really produce anything that has to do with that. Just typical heartbeats etc. But after around 30 mins I get this "Inavlid Webhook Token" error Alright, so it now returned a 429. So it's basically the interactoin webhook route being rate limited? Does Dpy use a different route? Here's the headers:
{
statusCode: 429,
headers: {
date: 'Mon, 05 Jun 2023 13:58:24 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '16',
connection: 'close',
'retry-after': '2322',
'x-frame-options': 'SAMEORIGIN',
'referrer-policy': 'same-origin',
'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
expires: 'Thu, 01 Jan 1970 00:00:01 GMT',
'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=[Token removed]"}],"group":"cf-nel","max_age":604800}',
nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'content-security-policy': "frame-ancestors 'none'; default-src 'none'",
server: 'cloudflare',
'cf-ray': '7d28ee233fb20a70-AMS',
'alt-svc': 'h3=":443"; ma=86400'
}
{
statusCode: 429,
headers: {
date: 'Mon, 05 Jun 2023 13:58:24 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '16',
connection: 'close',
'retry-after': '2322',
'x-frame-options': 'SAMEORIGIN',
'referrer-policy': 'same-origin',
'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
expires: 'Thu, 01 Jan 1970 00:00:01 GMT',
'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=[Token removed]"}],"group":"cf-nel","max_age":604800}',
nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'content-security-policy': "frame-ancestors 'none'; default-src 'none'",
server: 'cloudflare',
'cf-ray': '7d28ee233fb20a70-AMS',
'alt-svc': 'h3=":443"; ma=86400'
}
Thought that... It's pretty much impossible to find this bot/these bots... So CF can also rate limit specific endpoints? Since everything else works I get it everytime I wanna use editReply()
{
statusCode: 429,
headers: {
date: 'Mon, 05 Jun 2023 19:23:37 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '16',
connection: 'close',
'retry-after': '1051',
'x-frame-options': 'SAMEORIGIN',
'referrer-policy': 'same-origin',
'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
expires: 'Thu, 01 Jan 1970 00:00:01 GMT',
'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=[Token removed]"}],"group":"cf-nel","max_age":604800}',
nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'content-security-policy': "frame-ancestors 'none'; default-src 'none'",
server: 'cloudflare',
'cf-ray': '7d2aca896acc1ca6-AMS',
'alt-svc': 'h3=":443"; ma=86400'
},
trailers: {},
opaque: null,
body: BodyReadable {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 65536,
buffer: BufferList { head: [Object], tail: [Object], length: 1 },
length: 16,
pipes: [],
flowing: null,
ended: true,
endEmitted: false,
reading: false,
constructed: true,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
_read: [Function: bound resume],
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
[Symbol(kCapture)]: false,
[Symbol(abort)]: [Function (anonymous)],
[Symbol(kConsume)]: null,
[Symbol(kBody)]: null,
[Symbol(kContentType)]: 'text/plain; charset=UTF-8',
[Symbol(kReading)]: false
},
context: undefined
}
{
statusCode: 429,
headers: {
date: 'Mon, 05 Jun 2023 19:23:37 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '16',
connection: 'close',
'retry-after': '1051',
'x-frame-options': 'SAMEORIGIN',
'referrer-policy': 'same-origin',
'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
expires: 'Thu, 01 Jan 1970 00:00:01 GMT',
'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=[Token removed]"}],"group":"cf-nel","max_age":604800}',
nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'content-security-policy': "frame-ancestors 'none'; default-src 'none'",
server: 'cloudflare',
'cf-ray': '7d2aca896acc1ca6-AMS',
'alt-svc': 'h3=":443"; ma=86400'
},
trailers: {},
opaque: null,
body: BodyReadable {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 65536,
buffer: BufferList { head: [Object], tail: [Object], length: 1 },
length: 16,
pipes: [],
flowing: null,
ended: true,
endEmitted: false,
reading: false,
constructed: true,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
_read: [Function: bound resume],
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
[Symbol(kCapture)]: false,
[Symbol(abort)]: [Function (anonymous)],
[Symbol(kConsume)]: null,
[Symbol(kBody)]: null,
[Symbol(kContentType)]: 'text/plain; charset=UTF-8',
[Symbol(kReading)]: false
},
context: undefined
}
[REST Global(PATCH:/webhooks/:id/things/messages/@original):999740568093605998] Encountered unexpected 429 rate limit
Global : false
Method : PATCH
URL : https://discord.com/api/v10/webhooks/things/messages/@original
Bucket : /webhooks/:id/things/messages/@original
Major parameter: 999740568093605998
Hash : Global(PATCH:/webhooks/:id/things/messages/@original)
Limit : Infinity
Retry After : 1051050ms
Sublimit : 1051050ms
[REST Global(PATCH:/webhooks/:id/things/messages/@original):999740568093605998] Encountered unexpected 429 rate limit
Global : false
Method : PATCH
URL : https://discord.com/api/v10/webhooks/things/messages/@original
Bucket : /webhooks/:id/things/messages/@original
Major parameter: 999740568093605998
Hash : Global(PATCH:/webhooks/:id/things/messages/@original)
Limit : Infinity
Retry After : 1051050ms
Sublimit : 1051050ms
Why exactly? I just wanted to ask if applying for an increased global rate limit would help, but Discord even says:"Interaction endpoints are not bound to the bot's Global Rate Limit."... I just compared the implementations of D.py and D.js and they do it the exact same way. I think a friend just didn't test it properly when he said that it works in Py. I asked him to test it again. Is there any potential fix for this? We can't control the behavior of the bots on this server for the most part. Is it possible to request increased rate limits bound to IP? I'm talking about hosting servers, yeah Well, the Docker container these bots are running on Yes, we are running the host
Want results from more Discord servers?
Add your server