discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.49k stars 3.97k forks source link

Embed isn't sending #7847

Closed its-mrarsikk closed 2 years ago

its-mrarsikk commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

Hello! I am writing a bot, and i have 2 commands, that sends embeds. No one of them sends embeds, what i don't want. You can look at codes of both in code samples.

Code sample

// First command with plain text
const membed = new Discord.MessageEmbed()
  .setColor('#0099ff')
  .setTitle('MuzPro Help')
  .setDescription('List of commands and aliases.')
  .addFields({
      name: '▶ Play',
      value: 'Plays the specified song.\nAliases: p, go, m'
   }, {
      name: '⏹ Stop',
      value: 'Disconnects the bot.\nAliases: s, disconnect, dis, d, stfu, shut'
   }, {
      name: '📘 Info [HELPER]',
      value: 'Displays an info embed.',
      inline: true
   }, {
      name: '📘 Help [HELPER]',
      value: 'Displays this embed.',
      inline: true
   })
   .setTimestamp()
   .setFooter({
       text: 'MuzPro'
   });

message.channel.send('**Plain text**', {
    embed: membed
}); // Sent plain text without embed

// Only embed
const membed = new Discord.MessageEmbed()
    .setTitle("About MuzPro")
    .setColor(0x00AE86)
    .setDescription("Hello! This is a basic music bot! Run m!help for command list! Written by <@867220425276260353>.")
    .setFooter("MuzPro bot", "https://i.imgur.com/7LxOFKY.png")
    .setImage("https://i.imgur.com/7LxOFKY.png");
message.channel.send({
    embed: membed
}) // Error:
Uncaught DiscordAPIError DiscordAPIError: Cannot send an empty message
    at DiscordAPIError (undefined:9:5)
    at execute (undefined:350:13)
    at processTicksAndRejections (undefined:96:5)

Package version:

13.6.0

Node.js version:

17.3.1

Operating system:

Windows 10 Pro x64

Priority this issue should have:

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildVoiceStates, GuildMessages

I have tested this issue on a development release:

I did not

Mateo-tem commented 2 years ago

You need to use 'embeds' instead of 'embed'.

- message.channel.send({ embed: [membed] })
+ message.channel.send({ embeds: [membed] })
its-mrarsikk commented 2 years ago

@Mateo-tem Only message without plain text were sent. image

Syjalo commented 2 years ago

Sending and editing now takes only a single object parameter

- channel.send(embed);
+ channel.send({ embeds: [embed, embed2] });
- channel.send('Hello!', { embed });
+ channel.send({ content: 'Hello!', embeds: [embed, embed2] });

Full migration guide to discord.js v13: https://discordjs.guide/additional-info/changes-in-v13.html

Syjalo commented 2 years ago

@its-mrarsikk use the issue tracker only for bug reports and enhancement suggestions. This isn't a bug. If you have a question, please ask it in the Discord server instead of opening an issue.