Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda