Discord.js | guild.iconURL not working in embed

Viewed 13840

I've been trying to show the server's icon in the serverinfo embed, but it won't show up.

var serverIcon = message.guild.iconURL;
const serverInfoEmbed = new Discord.MessageEmbed()
  .setTitle('server info')
  .setColor(0x348a58)
  .addField('owner', message.guild.owner, true)
  .addField('name', '`' + message.guild.name + '`', true)
  .addField('members', '`' + message.guild.memberCount + '`', true)
  .setThumbnail(serverIcon)
  .setFooter('very bootiful server');

setTimeout(() => { message.channel.send(serverInfoEmbed) }, 200);
console.log(serverIcon);

in the console, it says:

[Function: iconURL]

I tried to put it directly as the thumbnail .setThumbnail(message.guild.iconURL) but it still didn't work.

1 Answers

It's because guild.iconURL() is a function, and you would need to replace your line :

var serverIcon = message.guild.iconURL;

with :

var serverIcon = message.guild.iconURL();

I also suggest you to read the docs for more info :)

Related