我如何让我的 discord 从 gif 中识别出 png?

How do i make my discord recognize png from gifs?

我试图让我的 discord 机器人打印出用户头像,但我不知道如果作者头像是 png(或任何其他静止图像)或 gif,如何让机器人重新识别。

module.exports.run = async (bot, message, args) => {
  message.channel.send({files: [
{
  attachment: message.author.displayAvatarURL,
  name: "avatar.png"
}
]});
}
 module.exports.help = {
 name: "avatar"
}

discord.js documentation, the property avatarURL from the User class provides the full URL to access the resource. That address probably includes the file's extension, which you could easily check with string methods like .endsWith() 中所见。