#error with discord embed

14 messages · Page 1 of 1 (latest)

proven timber
#
interaction.channel.send({
    embeds: [generateEmbed(0)],
    components: canFitInOnePage
      ? []
      : [new ActionRowBuilder({components: [forwardButton]})]
  }).then(embedMessage=>{
       //do stuff
})

    const current = guilds.slice(start, start + 10)

  // You can of course customise this embed however you want
  var embedd = new Discord.EmbedBuilder()
    return await new EmbedBuilder({
        title: `Showing results ${start}-${start + current.length} out of ${guilds.length} results for you`,
        thumbnail: "https://i.imgur.com/gDRJiSZ.png",
        author: {name: "EMC Shop Search"},
            fields:
          current.map(guild => ({
            name: "ID[" + guild.ID + "]  |  " + dd["username"] + " - " + "/n spawn " + guild.nation,
                          value: "`" + guild.item + " - " +  guild.itemcount + " for " + guild.price +" gold`"  + " `"+ guild.other + "`" + " \nStocked : " + guild.stock + "\nBUYING: " + guild.buying
 
          }))
        
      })
}

It tells me " Cannot send empty message" error but the first embed is still sent ?

What's wrong?

onyx basinBOT
#

• 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.

modest dust
#

This may not be related to your error. But I think you should use the setter method rather than directly setting properties.
ex.

new EmbedBuilder().setTitle('ex').setAuthor('Cat')

plush kernel
#

Yea, use the actual setters, way smarter

meager linden
#

Also that await is totally useless there and makes your code look weird

proven timber
#

I’ll use the setter method thank you

proven timber
modest dust
#

it's not a problem But there's no need to do that.

void wolf
proven timber
#

all right

lunar solstice
proven timber
# lunar solstice yes because awaiting synchronous code will return a pending promise that won't r...

I changed it to this:


  const current = guilds.slice(start, start + 10)

// You can of course customise this embed however you want
  return new EmbedBuilder().setTitle(`Showing results ${start}-${start + current.length} out of ${guilds.length} results for you`)
  .setThumbnail("https://i.imgur.com/gDRJiSZ.png").setAuthor({name: "EMC Shop Search"})
  .addFields(current.map(guild => ({
    name: "ID[" + guild.ID + "]  |  " + dd["username"] + " - " + "/n spawn " + guild.nation,
                        value: "`" + guild.item + " - " +  guild.itemcount + " for " + guild.price +" gold`"  + " `"+ guild.other + "`" + " \nStocked : " + guild.stock + "\nBUYING: " + guild.buying

  })))
}

it sends the embed and then tells me that the message is empty, and theres no specified line in the error

proven timber
#

But the weird thing is that it sends the embed, and tells afterwards its an empty msg