Adam
Adam

Reputation: 21

discord.js command on avatar

I have a problem with the avatar display command. It keep saying this:

TypeError: Cannot read property 'members' of undefined

Code:

const { Client, Message, MessageEmbed } = require('discord.js')

module.exports = {

    name: 'avatar',
    execute: async(client, message, args) => {
        const member = message.mentions.members.first() || message.member;

        message.channel.send(
            new MessageEmbed()
            .setTitle(`${member.user.tag}'s avatar`)
            .setImage(member.user.displayAvatarURL({ dynamic: true, size: 512}))
            .setColor('RED')
        );
    },
};

Upvotes: 2

Views: 220

Answers (1)

MrMythical
MrMythical

Reputation: 9041

The only explanation here is that you passed your parameters in the wrong order. Your declaration is like this:

(client, message, args)

however your execution parameters are passed in incorrectly. I suspect they might look something like this:

(message, client, args)

but they must be in the right order

(client, message, args)

Upvotes: 1

Related Questions