【问题标题】:Why this avatarURL() didn't work on discordjs?为什么这个 avatarURL() 在 discordjs 上不起作用?
【发布时间】:2022-06-14 00:19:48
【问题描述】:

所以我想制作贺卡,当有人加入时,它会发送有关用户名等的信息,一切都很好,但不是 .setThumbnail(member.avatarURL()) 我不知道为什么它不起作用。

这是我的完整代码

// ---- GREETINGS ----
client.on('guildMemberAdd', member => {
    const exampleEmbed = new MessageEmbed()
    .setTitle('Wellcome to the server :hatching_chick: ')
    .setDescription(`Hello <@${member.id}> don't forget to register ^^`)
    .setThumbnail(member.avatarURL())
    .setFooter({ text: "Please read pinned messages",
    iconURL: 'https://s3.getstickerpack.com/8c0f922eae5097'});
    member.guild.channels.cache.get('981582630317338656').send({ embeds: [exampleEmbed] });
});

【问题讨论】:

  • 如果会员没有头像图片(有默认Discord头像)avatarURL()会返回null。使用displayAvatarURL() 处理默认头像。

标签: discord discord.js


【解决方案1】:

我使用.setThumbnail(member.displayAvatarURL()) 谢谢@Elitezen

【讨论】:

    猜你喜欢
    • 2018-05-23
    • 2022-08-02
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    相关资源
    最近更新 更多