Im trying to make a sudo command but the user i mention in args 0's Profile picture wont show.
async execute(client, message, args) {
if (!message.member.hasPermission("MANAGE_WEBHOOKS")) {
return message.channel.send(`You don't have permission to execute this command.`)}
message.delete();
let user =
message.mentions.members.first() ||
message.guild.members.cache.get(args[0]) ||
message.member.id();
if (!user) return message.channel.send("Please provide a user!");
const webhook = await message.channel.createWebhook(user.displayName, {
avatar: user.user.displayAvatarURL(),
channel: message.channel.id
});
await webhook.send(args.slice(1).join(" ")).then(() => {
webhook.delete();
});
}
A couple of things:
Your declaration of user (let user =) is a bit misleading when you are fetching a member object from the cache. I would recommend changing it to member instead for coherency.
Smallketchup82 is correct. Because you are getting a member object you would need to use the .user attribute to get anything pertaining to the user portion (username, tag, discriminator, and avatar).
If you were to follow the above advice you could do something like:
avatar: member.user.avatarURL()
I'm not entirely sure of which method gets the user's avatar as I have only worked with discordjs v13. However, its most likely one of the two:
member.user.displayAvatarURL()member.user.avatarURL()