我正在尝试使我的不和谐机器人打印出用户头像,但是如果作者的头像是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中所见,avatarURL
类的属性User
提供了访问资源的完整URL。该地址可能包含文件的扩展名,您可以使用.endsWith()之类的字符串方法轻松检查该扩展名。