Search code examples
discorddiscord.jsdeprecateddeprecation-warning

DeprecationWarning: Passing strings for MessageEmbed#setAuthor is deprecated


I'm working on a discord bot, when a user joins/leaves the server there's a message for that, but I'm getting a warning in my terminal that says DeprecationWarning: Passing strings for MessageEmbed#setAuthor is deprecated

Here is some of the code in case you need it.

const Welcome = new MessageEmbed()
    .setColor("RED")
    .setAuthor(user.tag, user.avatarURL({dynamic: true, size: 512}))
    .setThumbnail(user.avatarURL({dynamic: true, size: 512}))
    .setDescription(`
    Welcome ${member} to **${guild.name}!**`)
    .setFooter({
      text: `${user.id}`
    })

Solution

  • It's just a deprecation warning. You can safely ignore it.

    It means that in a future version of the Discord client, you won't be able to use the function setAuthor.

    There's usually a replacement function or alternate method for it in newer versions but if you don't plan on upgrading then you can ignore it.

    You should, however, always upgrade your dependencies as they can contain bug fixes and security updates.

    In your case, Discord specifies that setAuthor accepts an object in newer versions (although you can still use a string in your version).

    Check the Discord JS Docs for more information.