'Is there a way to Syntax Highlight on Discord.js but also put in a function call?

I'm trying to make something like this;

Shows the statistics but is syntax highlighted

but my issue is when I'm in my code, I can't call the statistics from the API and put it into a syntax highlight.

[It is put into syntax highlight, but will not pull the needed information from the api.2

My embed's code is

.addField(
    {
        name: [${player.stats.bedwars.level}✫] ${player.rank} ${player}`,
        value: "`Note: If ${player}'s WS is 0, their API may be off.`"
    }
)


Solution 1:[1]

  • You're supposed to use the template literals properly.
.addFields([
   {
      name: `[${player.stats.bedwars.level}?] ${player.rank} ${player}`,
      value: `\`Note: If ${player}'s WS is 0, their API may be off.\``
   }
])
  • You need to use addFields() for an array of fields, OR
  • You could use .addField() with only 2 parameters and you're job is done!
.addField(`[${player.stats.bedwars.level}?] ${player.rank} ${player}`, `\`Note: If ${player}'s WS is 0, their API may be off.\``)
  • Using a backslash (\) will help you use template literals inside template literals.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Darshan B