Home > Blockchain >  How can I print the content of author.name and description(embed)?
How can I print the content of author.name and description(embed)?

Time:09-24

I want to print the content of author.name an description of an embed, but I have no idea how.

Error:
Uncaught ReferenceError: author is not defined
const user = author.name;
  message.channel.send(`${user} !!!`);
  console.log(`${user} !!!`);

Example I want to return the name "Juan" of .setAuthor and "text" of .setDescription from the embed , It is not the name of the author of the message

const embed = new MessageEmbed()
    .setAuthor('Juan')
    .setColor('RANDOM')
    .setDescription("text")
      message.channel.send(embed);

CodePudding user response:

Sounds like you need to use message.author.username

client.on((message) => {
const username = message.author.username;
  message.channel.send(`${username} !!!`);
  console.log(`${username} !!!`);
})

CodePudding user response:

problem solved

if(message.embeds.length >= 0) 
  {
    let embed = message.embeds
    for(let i = 0; i < embed.length; i  )
    {
      if (!embed[i] || !embed[i].author || embed[i].author.name === null) return;
      {
      const string4 = (embed[i].author.name);
      message.channel.send(string4)
      }
    }
  }
  • Related