Home > Net >  Discord.js Exception embed author name has to be a string only accurse on Heroku
Discord.js Exception embed author name has to be a string only accurse on Heroku

Time:07-17

Hello Im having an utterly bizzare issue

Basically im currently trying to make an embed

        const error_embed = new Discord.MessageEmbed()
        .setColor('#c00be0')
        .setTitle("To use this command please mention a user")
        .setAuthor({ name: msg.author.tag   ' ', iconURL: msg.author.avatarURL() })

This is my current code

Now something utterly bizzare happens

Whenever im testing this code on my local machine it works perfectly without an issue

However whenever I deploy the code on Heroku it for some reason fails with the exception

MessageEmbed author name must be a string

If you dont know a lot about heroku please note that

Heroku uses the same node engine that I am using

Heroku uses the same discord.js version I am using

I have tried a few things to troubleshoot the issue

I first attempted to make the name a normal non variable string

this failed again

I also attempted to convert the content of the variable to string via the string.toString() method

Please note that this issue is for some reason exclusive to heroku

The code is the same

The modules are the same

The node version is the same

and it works perfectly on my pc

CodePudding user response:

try this:

let author = {}
author.name = msg.author.tag.toString()
author.iconURL = msg.author.avatarURL()
  const error_embed = new Discord.MessageEmbed()
        .setColor('#c00be0')
        .setTitle("To use this command please mention a user")
        .setAuthor(author)

Making an empty object and adding values is usually less buggy than having an object with the keys and values inside. Also, try using .toString()

CodePudding user response:

It looks as youre trying to pass an object as a string! That constructor requires the setAuthor property to be a string. You can instead try to do

const author;
author = msg.author.tag.toString();

Hope this works for ya!

  • Related