Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
TypeError: Cannot read properties of undefined (reading 'member')

Can someone help me figure out this error? I really dont know what to do. I tried my best to get rid of this error, but nothing worked. I will be very grateful if you try to help me. This code is supposed to give you basic information about user that you pinged.enter image description here

const Command = require("../Structures/Command.js");

/**
 * @param {Client} client
 * @param {Message} message
 * @param {String[]} args 
 */

module.exports = new Command({
    name: "userinfo",
    description: 'info',

    async run(client, message, args) {
        const user = message.mentions.member.first() || message.member.user.username;
        const member = message.guild.members.cache.get(user.id);

        const embed = new MessageEmbed()
            .setColor('DARK_RED')
            .setAuthor({ name: user.username, iconURL: user.avatarURL({ dynamic: true }) })
            .setDescription("Kdo to je")
            .setThumbnail(user.displayAvatarURL({ dynamic: true }))
            .addFields(
            { name: "Username", value: user.username, inline: true }, 
            { name: "Tag", value: user.discriminator, inline: true }, 
            { name: "Bot", value: user.bot, inline: true }, 
            { name: "Nickname", value: member.nickname || "None", inline: true },
            { name: "Joined:", value: new Date(member.joinedTimestamp()).toDateString(), inline: true },
            { name: "Discord user since:", value: new Date(user.createdTimestamp()).toDateString(), inline: true },
            { name: "Roles count:", value: member.roles.cache - 1, inline: true },

            )

        return message.channel.send({ embeds: [embed] });
    }

})

Im also sharing my simple command handler, because its used in this code.

const Client = require("./Client.js");

/**
 * @param {Discord.Message} message 
 * @param {string[]} args 
 * @param {Client} client 
 */
function RunFunction(message, args, client) {}


class Command {

    /**
     * @typedef {{name: string, description: string, run: RunFunction}} CommandOptions
     * @param {CommandOptions} options 
     */
    constructor(options) {
        this.name = options.name;
        this.description = options.description;
        this.permission = options.permission;
        this.run = options.run;
    }
}

module.exports = Command;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One of the following does not contain object:

message.mentions.member or message.member or message.guild.members

Therefore when you try to access i.e. message.mentions.member.first() it fails, because you try to call something like undefined.first()

You should log (or debug) the whole message parameter and see what is actually inside.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda