Recurring "Cannot send an empty message" error

Hello, I'm intermittently getting hit with 50006 "Cannot send an empty message" errors in a production environment using discord.js. I can't seem to find any pattern aside from the fact that it occurs when sending attachments, specifically text files I've created server-side. Simply running a command multiple times will sometimes succeed and sometimes fail. Any ideas as to why this could be happening?!
70 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!
Nexunity Founder
Hello
will
will2mo ago
Here is the full error:
DiscordAPIError[50006]: Cannot send an empty message
at new _DiscordAPIError (./node_modules/@discordjs/rest/dist/index.js:583:9)
at <anonymous> (./node_modules/@discordjs/rest/dist/index.js:726:111)
at processTicksAndRejections (:12:39) {
requestBody: [Object],
rawError: [Object],
code: 50006,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/.../messages',
originalLine: 472,
originalColumn: 12
}
DiscordAPIError[50006]: Cannot send an empty message
at new _DiscordAPIError (./node_modules/@discordjs/rest/dist/index.js:583:9)
at <anonymous> (./node_modules/@discordjs/rest/dist/index.js:726:111)
at processTicksAndRejections (:12:39) {
requestBody: [Object],
rawError: [Object],
code: 50006,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/.../messages',
originalLine: 472,
originalColumn: 12
}
The code is a bit complex and spans multiple files/functions, but in the end the important part is:
const attachments = [new AttachmentBuilder(Buffer.from(`# Before\n\n${oldContent}\n\n# After\n\n${newContent}`), {
name: `${newMessage.id}-content-changes.txt`,
description: `A file containing the content changes from the message ${newMessage.id} at ${Date.now()}`,
})];

// ...

targetChannel.fetch().then((channel) => channel.send({ embeds: [embed], files: attachments }));
const attachments = [new AttachmentBuilder(Buffer.from(`# Before\n\n${oldContent}\n\n# After\n\n${newContent}`), {
name: `${newMessage.id}-content-changes.txt`,
description: `A file containing the content changes from the message ${newMessage.id} at ${Date.now()}`,
})];

// ...

targetChannel.fetch().then((channel) => channel.send({ embeds: [embed], files: attachments }));
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Nexunity Founder
Hello
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Nexunity Founder
I'm.here to help
will
will2mo ago
The issue occurs without embeds as well (even if that parameter isn't provided)
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Nexunity Founder
??
will
will2mo ago
Agreed! and this only started happening suddenly without any noticeable cause The production environment also has the same dependency and node versions
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
will
will2mo ago
Dependencies:
├── @eejit/eslint-config-typescript@11.3.0
├── @eejit/prettier-config@3.0.0
├── @types/color-convert@2.0.3
├── @types/node-cron@3.0.11
├── @types/shelljs@0.8.15
├── bufferutil@4.0.8
├── bun-types@1.1.20
├── camelcase@8.0.0
├── chalk@5.3.0
├── color-convert@2.0.1
├── consola@3.2.3
├── discord-html-transcripts@3.2.0
├── discord.js@14.15.3
├── emoji-regex@10.3.0
├── esbuild@0.23.0
├── google-translate-api-x@10.6.8
├── hypixel-api-reborn@11.2.1
├── minecraft-data@3.67.0
├── mongoose@8.5.1
├── node-cron@3.0.3
├── shelljs@0.8.5
├── tree-kill@1.2.2
├── typescript@5.5.3
└── utf-8-validate@6.0.4
├── @eejit/eslint-config-typescript@11.3.0
├── @eejit/prettier-config@3.0.0
├── @types/color-convert@2.0.3
├── @types/node-cron@3.0.11
├── @types/shelljs@0.8.15
├── bufferutil@4.0.8
├── bun-types@1.1.20
├── camelcase@8.0.0
├── chalk@5.3.0
├── color-convert@2.0.1
├── consola@3.2.3
├── discord-html-transcripts@3.2.0
├── discord.js@14.15.3
├── emoji-regex@10.3.0
├── esbuild@0.23.0
├── google-translate-api-x@10.6.8
├── hypixel-api-reborn@11.2.1
├── minecraft-data@3.67.0
├── mongoose@8.5.1
├── node-cron@3.0.3
├── shelljs@0.8.5
├── tree-kill@1.2.2
├── typescript@5.5.3
└── utf-8-validate@6.0.4
Node: v22.4.1 Bun: 1.1.20 (not actually sure if that is the same in production now that I think about it) I've also tested without bufferutil and utf-8-validate, though the issue persisted
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Nexunity Founder
I'm here to helpppppp
Want results from more Discord servers?
Add your server