嗨,我有这个头像命令,我想知道你是否可以用他们的ID来代替提到一个用户
if(command === "avatar" || command === "av") {
const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author
if (!user) {
user = message.author;
}
const member = message.guild.member(user)
const avatar = user.avatarURL({dynamic:true})
if (!avatar) return message.channel.send("This user doesn't have an avatar to show")
const embed = new Discord.MessageEmbed()
.setTitle(`${user.username}'s avatar`)
.setColor('RANDOM')
.setDescription(`[Click here for the image link](${avatar})`)
.setImage(avatar)
.setFooter(`${client.user.username} 2021`)
.setTimestamp()
message.channel.send(embed)
发布于 2021-01-28 19:48:11
我建议使用message.guild.members.cache.get(args[0]).user
,而不是使用client.users.cache.get(args[0])
,这样它就会获得一个成员(而不是用户),然后从该成员中选择用户。还要确保您在开发人员门户上启用了intents,因为没有它们,这将无法工作。
要启用它们,只需选择您的应用程序,然后进入机器人选项卡,向下滚动一点,并确保两个意图都被选中。
https://stackoverflow.com/questions/65928342
复制相似问题