不和谐音头像显示代码未运行



我想使用命令"-ava @(user)"显示指定用户的头像。我创建了这个代码,但我不知道为什么当我在不和谐的地方键入命令,没有返回任何东西。下面是我的discord bot的代码:

const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require('discord.js');
module.exports = {
name: 'ava',
description: 'Provide user with certain avatar as requested.',
execute(message, args) {
if (args[0]) {
const user = message.mentions.users.first();
if (!user) return message.reply('Please mention a user to access their avatar');
const otherIconEmbed = new Discord.RichEmbed()
.setTitle(`${user.username}'s Avatar`)
.setImage(user.displayAvatarURL);
message.channel.send(otherIconEmbed).catch(err => console.log(err));
}
const myIconEmbed = new Discord.RichEmbed()
.setTitle(`${message.author.username}'s avatar!`)
.setImage(message.author.displayAvatarURL);
message.channel.send(myIconEmbed).catch(err => console.log(err));
}
}

只要在displayAvatarURL后面加上()就可以得到displayAvatarURL ()如果你想让它动画化就必须加上displayAvatarURL ({dynamic: true})🙂

最新更新