Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使我的不和谐从GIF中识别png?_Javascript_Bots_Discord_Discord.js_Gif - Fatal编程技术网

Javascript 如何使我的不和谐从GIF中识别png?

Javascript 如何使我的不和谐从GIF中识别png?,javascript,bots,discord,discord.js,gif,Javascript,Bots,Discord,Discord.js,Gif,我试图让我的discord机器人打印出用户的头像,但如果作者的头像是png(或任何其他静止图像)或gif,我不知道如何让机器人识别 如中所示,来自User类的属性avatarURL提供了访问资源的完整URL。该地址可能包含文件的扩展名,您可以使用字符串方法轻松检查该扩展名,如。查看这是否有帮助 module.exports.run = async (bot, message, args) => { message.channel.send({files: [ { attachmen

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

如中所示,来自
User
类的属性
avatarURL
提供了访问资源的完整URL。该地址可能包含文件的扩展名,您可以使用字符串方法轻松检查该扩展名,如。

查看这是否有帮助
module.exports.run = async (bot, message, args) => {
  message.channel.send({files: [
{
  attachment: message.author.displayAvatarURL,
  name: "avatar.png"
}
]});
}
 module.exports.help = {
 name: "avatar"
}