Discord Embed not sending
Code
embed.toJSON()
if (previousTokenAddress !== rowData.tokenAddress) {
console.log('rowData:', rowData); // Log rowData to check its values
const embed = new EmbedBuilder()
.setTitle(rowData.tokenName)
.addFields(
{ name: 'Token Address', value: rowData.tokenAddress },
{ name: 'Amount', value: rowData.amount })
.setImage(rowData.tokenImage)
.setFooter({ text: rowData.timestamp, icon_url: rowData.tokenImage});
console.log('Embed:', embed.toJSON());
previousTokenAddress = rowData.tokenAddress; // Update previous token address
const channel = await discordClient.channels.fetch('1217259060227866664');
await channel.send({ embed });
}
if (previousTokenAddress !== rowData.tokenAddress) {
console.log('rowData:', rowData); // Log rowData to check its values
const embed = new EmbedBuilder()
.setTitle(rowData.tokenName)
.addFields(
{ name: 'Token Address', value: rowData.tokenAddress },
{ name: 'Amount', value: rowData.amount })
.setImage(rowData.tokenImage)
.setFooter({ text: rowData.timestamp, icon_url: rowData.tokenImage});
console.log('Embed:', embed.toJSON());
previousTokenAddress = rowData.tokenAddress; // Update previous token address
const channel = await discordClient.channels.fetch('1217259060227866664');
await channel.send({ embed });
}
rowData: {
timestamp: '19 minutes ago',
amount: '+ 422,485.52',
tokenName: 'dibats',
tokenImage: 'https://bafkreibznbc5gktcsujoogybiphcmk46fekxlelly3v4x5sgh6e52qtrye.ipfs.nftstorage.link',
tokenAddress: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
Embed: {
title: 'dibats',
fields: [
{
name: 'Token Address',
value: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
]
}
rowData: {
timestamp: '19 minutes ago',
amount: '+ 422,485.52',
tokenName: 'dibats',
tokenImage: 'https://bafkreibznbc5gktcsujoogybiphcmk46fekxlelly3v4x5sgh6e52qtrye.ipfs.nftstorage.link',
tokenAddress: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
Embed: {
title: 'dibats',
fields: [
{
name: 'Token Address',
value: 'CXSnY5JHZcGKWApubGkjm1fAYnuTHYoTy5diPiYHVbjM'
}
]
}
5 Replies
- 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!Error
DiscordAPIError[50006]: Cannot send an empty message
at handleErrors (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async TextChannel.send (C:\Users\maike\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:155:15)
at async checkForUpdates (file:///C:/Users/maike/OneDrive/Documenten/Bureaublad/Python/Crypto/puppeteer-real-browser/src/walletTracker.js:124:9) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
rawError: { message: 'Cannot send an empty message', code: 50006 },
code: 50006,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1217259060227866664/messages'
}
DiscordAPIError[50006]: Cannot send an empty message
at handleErrors (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\maike\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async TextChannel.send (C:\Users\maike\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:155:15)
at async checkForUpdates (file:///C:/Users/maike/OneDrive/Documenten/Bureaublad/Python/Crypto/puppeteer-real-browser/src/walletTracker.js:124:9) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
rawError: { message: 'Cannot send an empty message', code: 50006 },
code: 50006,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1217259060227866664/messages'
}
await channel.send({embeds: [embed]})
That should work
and where do i fill in the channel id?
oh wait
nevermind
embed
was deprecated and removed in api v10, which is used by djs v14
use embeds: [embed]