Keep getting 500 Internal Server Error when editing messages

Hello discord.js community, Context Node version: 16.17.0 Discord js version: 14.9.0 I'm trying to implement a tournament calendar, that displays the next 50 tournaments of a game. The tournaments i'm getting from a third party api, and everything works how it supposed to on that end. The calendar is updating itself every 24h at 23:00 UTC. Updating the calendar 1. Fetch all upcoming tournaments 2. Build all embeds to send 3. Fetch all messages that are associated with the calendar (i save the snowflakes of the messages in the database, to check which messages are associated with that calendar) 4. Edit all messages with the new embeds. (Also delete/send new messages when there is a need for it) I limited the embeds per message at 9. For each update run of the calendar, im updating around 15 Messages. This means around 30 requests to the discord api. (15 for fetching and 15 for updating). These numbers might not be completely accurate but around the same ballpark should be the actual numbers. The error I get this error at least one time in an update run and it messes everything up, so that the calendar is not displayed correctly. I just cannot seem to find a fix for it.
HTTPError: Internal Server Error
at handleErrors (/node_modules/@discordjs/rest/dist/index.js:633:11)
at SequentialHandler.runRequest (/node_modules/@discordjs/rest/dist/index.js:1021:29)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async MessageManager.edit (/node_modules/discord.js/src/managers/MessageManager.js:176:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 0,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
status: 500,
method: 'PATCH',
url: 'https://discord.com/api/v10/channels/{channelId}/messages/{messageID}'
}
HTTPError: Internal Server Error
at handleErrors (/node_modules/@discordjs/rest/dist/index.js:633:11)
at SequentialHandler.runRequest (/node_modules/@discordjs/rest/dist/index.js:1021:29)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async MessageManager.edit (/node_modules/discord.js/src/managers/MessageManager.js:176:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 0,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
status: 500,
method: 'PATCH',
url: 'https://discord.com/api/v10/channels/{channelId}/messages/{messageID}'
}
The {channelId} and {messageId} are actual snowflakes in the error message. I also checked that the channel and message actualy exists and they both do for the past 5 times i got this error. What i already tried Spreading the requests, that not all come in at the same time (Fetch all messages, wait 1 second, then edit the messages) I thought it has something to do with rate limiting, but then i would see a 429 error status and not a 500. Thank you so much if you read this far. Any help would be appreciated.
5 Replies
d.js toolkit
d.js toolkit2mo 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! - Marked as resolved by OP
Kinect3000
Kinect30002mo ago
Internal Server Error either means that you provided a malformed request and Discord isn’t handling it properly to provide an error, or Discord is just having issues on their end
Jan_
Jan_2mo ago
But wouldn't a malformed request give me back a http status of 4xx?
Kinect3000
Kinect30002mo ago
…and Discord isn’t handling it properly to provide an error
Jan_
Jan_2mo ago
Ah, sorry misunderstood 😅 For anyone in the Future encountering this error After a few days of testing even more solutions. It seems the discord api has troubles when sending a lot of text/data with one send/edit message request. What i found out I tweaked the embeds per message and the amount of embeds per message. What i found is that 9 embeds with less text were just fine and less embeds per message but with more text were also fine. I checked and i am not going above the character limit on the embeds on any component or in whole. Conclusion From the findings the last option that i can think of is that the amount of data being send to the discord api was too huge, because when i sent the exact same embeds, that gave me the error, only with 5 embeds per message instead of 9, everything went fine. Same for 9 embeds per message but with less text per embed. So my takeaway from this "journey" is: Make sure you are not sending too much data per request to the discord api
Want results from more Discord servers?
Add your server