'Discord.JS Avatar Command using User ID

I want to use the avatar command using user id's/mentions. I was able to use mentions, however I am unable to use the user ids.

Here is my current code:

const Discord = require('discord.js');

module.exports = {
    name: 'avatar',
    description: 'avatar',
    aliases: ['av'],
    cooldown: 5,
    async execute(message, args) {
       let member = message.mentions.users.first() || message.guild.members.cache.get(args[0]) || message.author;
       let avatar = member.displayAvatarURL({ size: 1024, dynamic: true });

       const embed = new Discord.MessageEmbed()
        .setAuthor(avatar, message.username)
        .setTitle(`Avatar`)
        .setImage(avatar)
        .setColor("BLACK")
        .setAuthor(member.username, avatar, avatar);
        message.channel.send(embed);
    },
};

Whenever I run this code I receive this error:

Test Bot v1 ready!
(node:835) UnhandledPromiseRejectionWarning: TypeError: member.displayAvatarURL is not a function
    at Object.execute (/home/runner/no/commands/ping.js:13:28)
    at Client.<anonymous> (/home/runner/no/index.js:106:13)
    at Client.emit (events.js:314:20)
    at Client.EventEmitter.emit (domain.js:483:12)
    at MessageCreateAction.handle (/home/runner/no/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/runner/no/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/runner/no/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/home/runner/no/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/runner/no/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/runner/no/node_modules/ws/lib/event-target.js:132:16)
(node:835) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:835) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


Solution 1:[1]

Use this code

const Discord = require('discord.js');

module.exports = {
    name: 'avatar',
    description: 'avatar',
    aliases: ['av'],
    cooldown: 5,
    async execute(message, args) {
       let member = message.mentions.users.first() || message.guild.members.cache.get(args[0]) || message.member;
       let avatar = member.user.displayAvatarURL({ size: 1024, dynamic: true });

       const embed = new Discord.MessageEmbed()
        .setTitle(`${member.user.username}'s Avatar`)
        .setImage(avatar)
        .setColor("BLACK")
        .setAuthor(member.user.username);
        message.channel.send({embeds: [embed]});
    },
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 idk