JavaScript Embed Reply Broken

Ugh

PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> node .
Ready!
Bot is Now Online & Working Fine
Successfully registered application commands.
DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.reply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5)
    at async Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\events\interactionCreate.js:7:13) {
  method: 'post',
  path: '/interactions/970069776091193375/aW50ZXJhY3Rpb246OTcwMDY5Nzc2MDkxMTkzMzc1OjV2VFRMeTVlYnBQOWN4WFZ4Y0VzTUM1aDBuUTZhT0xJVk9FdlJmb2tPZGtyMGpGczFST3hsQUNkRWF5OTRJRW5hZG80eWZmMnp0UFJvc3FYNnhEc0UxUm1nbkRvT0V3cFYyNFhBdXFXZURGOGlOekl4R01oZ21xa3VJM0l0UDBD/callback',
  code: 50006,
  httpStatus: 400,
  requestData: { json: { type: 4, data: [Object] }, files: [] }
}
C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Unknown interaction
    at RequestHandler.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.reply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5) {
  method: 'post',
  path: '/interactions/970069776091193375/aW50ZXJhY3Rpb246OTcwMDY5Nzc2MDkxMTkzMzc1OjV2VFRMeTVlYnBQOWN4WFZ4Y0VzTUM1aDBuUTZhT0xJVk9FdlJmb2tPZGtyMGpGczFST3hsQUNkRWF5OTRJRW5hZG80eWZmMnp0UFJvc3FYNnhEc0UxUm1nbkRvT0V3cFYyNFhBdXFXZURGOGlOekl4R01oZ21xa3VJM0l0UDBD/callback',
  code: 10062,
  httpStatus: 404,
  requestData: {
    json: {
      type: 4,
      data: {
        content: 'An error occured while trying to execute this command!',
        tts: false,
        nonce: undefined,
        embeds: undefined,
        components: undefined,
        username: undefined,
        avatar_url: undefined,
        allowed_mentions: undefined,
        flags: 64,
        message_reference: undefined,
        attachments: undefined,
        sticker_ids: undefined
      }
    },
    files: []
  }
}

Node.js v17.7.1

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });

        return interaction.reply({ embed: exampleEmbed, ephemeral: true });

    },

};

Replace

with

interaction.reply({ embed: exampleEmbed, ephemeral: true });
PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> node index.js
Ready!
Bot is Now Online & Working Fine
C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Unknown interaction
    at RequestHandler.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.reply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5) {
  method: 'post',
  path: '/interactions/970225932398903307/aW50ZXJhY3Rpb246OTcwMjI1OTMyMzk4OTAzMzA3OkN2QmFRQmY5dEYxSHlVWGxXM1dhY3FqeVZwOTFBaWo1eEM5cVd2ZnBPUndzNUozZ0ppRFhGSVZETUtLdWc4d29mQzZOTzFIRUtsQTJUZzJmNWEzRVBpZDFwUjNPV21UNk1SV3A1TlFXTzVORWRCd3B4cTFrUlIxRkIzcTI5dWVS/callback',
  code: 10062,
  httpStatus: 404,
  requestData: {
    json: {
      type: 4,
      data: {
        content: undefined,
        tts: false,
        nonce: undefined,
        embeds: undefined,
        components: undefined,
        username: undefined,
        avatar_url: undefined,
        allowed_mentions: undefined,
        flags: 64,
        message_reference: undefined,
        attachments: undefined,
        sticker_ids: undefined
      }
    },
    files: []
  }
}

Node.js v17.7.1
PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> 
const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });

        interaction.reply({ embed: exampleEmbed, ephemeral: true });

    },

};

Try:

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
        
        interaction.reply('Working on it');
        interaction.editReply({ embed: exampleEmbed, ephemeral: true });

    },

};

When using slash commands you have 3 seconds to respond, it could be that for some reason it’s taking longer, for that reason we’ll add a “Loading phrase”.

I got a answer
image
But got this error.

Node.js v17.7.1
PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> node .
Ready!
Bot is Now Online & Working Fine
Successfully registered application commands.
C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:138
    if (!this.deferred && !this.replied) throw new Error('INTERACTION_NOT_REPLIED');
                                               ^

Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
    at CommandInteraction.editReply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:138:48)
    at Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\commands\help.js:50:21)
    at Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\events\interactionCreate.js:7:27)
    at Client.<anonymous> (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\index.js:22:44)
    at Client.emit (node:events:527:28)
    at InteractionCreateAction.handle (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:74:12)
    at Object.module.exports [as INTERACTION_CREATE] (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
    at WebSocketShard.onPacket (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)      
    at WebSocketShard.onMessage (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) {   
  [Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}

Node.js v17.7.1
PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot>

Wait, are we using asynchronous coding?

We can try use asynchronous coding:

Change it to:

        await interaction.reply('Working on it');
        await interaction.editReply({ embed: exampleEmbed, ephemeral: true });

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
        
        await interaction.reply('Working on it');
        await interaction.editReply({ embed: exampleEmbed, ephemeral: true });

    },

};

I don’t see an error this time.

Try remove await interaction.reply('Working on it'); & change
await interaction.editReply({ embed: exampleEmbed, ephemeral: true }) to become await interaction.reply({ embed: exampleEmbed, ephemeral: true })

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
        
        await interaction.editReply({ embed: exampleEmbed, ephemeral: true })
        await interaction.reply({ embed: exampleEmbed, ephemeral: true })

    },

};
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> node .
Ready!
Bot is Now Online & Working Fine
Successfully registered application commands.
Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
    at CommandInteraction.editReply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:138:48)
    at Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\commands\help.js:49:27)
    at Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\events\interactionCreate.js:7:27)
    at Client.<anonymous> (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\index.js:22:44)
    at Client.emit (node:events:527:28)
    at InteractionCreateAction.handle (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:74:12)
    at Object.module.exports [as INTERACTION_CREATE] (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
    at WebSocketShard.onPacket (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)      
    at WebSocketShard.onMessage (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) {   
  [Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}

The code is wrong.

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
        
        await interaction.reply({ embed: exampleEmbed, ephemeral: true })

    },

};

It should be like that.


Stuck on this.

const { SlashCommandBuilder } = require('@discordjs/builders');

const { MessageEmbed } = require('discord.js');

module.exports = {

    data: new SlashCommandBuilder()

        .setName('test')

        .setDescription('testing'),

    async execute(interaction) {

       const exampleEmbed = new MessageEmbed()

        .setColor('#0099ff')

        .setTitle('Some title')

        .setURL('https://discord.js.org/')

        .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })

        .setDescription('Some description here')

        .setThumbnail('https://i.imgur.com/AfFp7pu.png')

        .addFields(

        { name: 'Regular field title', value: 'Some value here' },

        { name: '\u200B', value: '\u200B' },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        { name: 'Inline field title', value: 'Some value here', inline: true },

        )

        . addField('Inline field title', 'Some value here', true)

        .setImage('https://i.imgur.com/AfFp7pu.png')

        .setTimestamp()

        .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
        
        await interaction.reply({ embed: exampleEmbed, ephemeral: true })

    },

};
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> node .
Ready!
Bot is Now Online & Working Fine
Successfully registered application commands.
DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.reply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5)
    at async Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\commands\help.js:49:9)
    at async Object.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\events\interactionCreate.js:7:13) {
  method: 'post',
  path: '/interactions/970378157217693757/aW50ZXJhY3Rpb246OTcwMzc4MTU3MjE3NjkzNzU3OlR3YVhKR1BjdzhNYkJYaktmQmY5SVMxU3U0STE3QnBJQTlySWhRbzlkd29lUmtma1JKWHlRWUVjMGZSSm9WVzBocnJXWG1IbkIxQVl6T0pnYVJrT1lsbnR0ZlZPNmdOQkR4ODRDQzhKR0JsUjN2alZpenRkaVdYQm4yZHBpQmtV/callback',
  code: 50006,
  httpStatus: 400,
  requestData: { json: { type: 4, data: [Object] }, files: [] }
}
C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Unknown interaction
    at RequestHandler.execute (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.reply (C:\Users\crazy\OneDrive\Desktop\sunset lodge bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5) {
  method: 'post',
  path: '/interactions/970378157217693757/aW50ZXJhY3Rpb246OTcwMzc4MTU3MjE3NjkzNzU3OlR3YVhKR1BjdzhNYkJYaktmQmY5SVMxU3U0STE3QnBJQTlySWhRbzlkd29lUmtma1JKWHlRWUVjMGZSSm9WVzBocnJXWG1IbkIxQVl6T0pnYVJrT1lsbnR0ZlZPNmdOQkR4ODRDQzhKR0JsUjN2alZpenRkaVdYQm4yZHBpQmtV/callback',
  code: 10062,
  httpStatus: 404,
  requestData: {
    json: {
      type: 4,
      data: {
        content: 'An error occured while trying to execute this command!',
        tts: false,
        nonce: undefined,
        embeds: undefined,
        components: undefined,
        username: undefined,
        avatar_url: undefined,
        allowed_mentions: undefined,
        flags: 64,
        message_reference: undefined,
        attachments: undefined,
        sticker_ids: undefined
      }
    },
    files: []
  }
}

Node.js v17.7.1
PS C:\Users\crazy\OneDrive\Desktop\sunset lodge bot> 

Strange, looks like there is an issue with the embed command, once again, I’m terrible in JS.

Maybe this will do something:

await interaction.reply({ content: ' ', ephemeral: true, embeds: [exampleEmbed ]})

IT WORKED!! THANK YOU SO MUCH

1 Like

No worries, in the python libary I use you don’t need to send “content”, you can just send the content as an embed.

Hope this helps though, happy developing!

This topic was automatically closed after 7 days. New replies are no longer allowed.