IceGod
IceGod

Reputation: 61

How to put both normal text and embed in the same message? discord.js

So I want to put both an embed and normal text in a single message. I think I already saw it, but if it is not possible, you can say it in the comments.

I tried a few probably dumb methods (I'm new to coding). Here is how I tried:

if (msg.startsWith(among + 'wiki')) {
 wikipog = message.content.slice(7);
 var embed = new Discord.MessageEmbed()
  .setTitle(':globe_with_meridians: Among Us Wiki :globe_with_meridians:')
  .setDescription('Down below is the page you asked for!')
  .addField(
   'If an image shows up down below, that means your page exists!',
   '\u200B'
  )
  .addField('\u200b', field)
  .setColor(color)
  .setFooter(footer);
 message.channel.send(embed, `https://among-us.fandom.com/wiki/${wikipog}`);
}

Thank you in advance!

(By the way, I know I can just do two message.channel.send(), but this would send two pings/notifications)

Upvotes: 4

Views: 8460

Answers (1)

Jakye
Jakye

Reputation: 6625

TextChannel#send accepts 2 parameters. The first one is the message content (text), and the second one is an object with options. You can set the embed in the options object.


const Embed = new Discord.MessageEmbed()
 .setTitle('Title')
 .setDescription('This is an embed message')
 .setColor('RED');

message.channel.send('This is a normal message.', {
 embed: Embed,
});

Update for DiscordJS 13

TextChannel#send takes one argument of type string | MessagePayload | MessageOptions. MessageOptions allows you to specify both content and embeds:

const Embed = /* ... */;

message.channel.send({
  content: 'This is a normal message.',
  embeds: [Embed],
});

Upvotes: 10

Related Questions