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

123
Vistas
Cannot read properties of undefined (reading members)

I'm trying to make an embed command which will include the user in it, but every time I try and run it, I get an error about reading members, and I'm not sure how to fix it.

const Discord = require('discord.js')

module.exports = {
  name: 'giveaway',
  description: 'sends giveaway info',
execute(client, message, args) {
    const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
    
    if(!args[0]) return message.channel.send('Please specify a user');
    
    if(!member) return message.channel.send('I can\'t seem to find this user.')
    
    const gaembed = new Discord.MessageEmbed()
    .setTitle('Congratulations', member)
    .setColor('GREEN')
    .setFooter('You have 24 hours from this message to claim your prize.')
    .setTimestamp()
    .setDescription('Congratulations! You have won a prize! Be sure to DM <@myuserid> to claim it, before it is rerolled.')
    message.channel.send(gaembed);
  },
};

This is the command handler in my index file:

client.on('message', message => {
        
    if (!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(' ');
    const commandName = args.shift().toLowerCase();

    const command = client.commands.get(commandName)
        || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
    
    if(!command) return;
    
    try {
        command.execute(message, args, client)
    } catch (error) {
        console.error(error);
        message.reply('There was an error trying to execute that command! Check the console for more details!');
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to fix the order of the arguments:

// wrong
execute(client, message, args) {

should be this:

// correct
execute(message, args, client) {

As in your index file, you call it with arguments in this order (command.execute(message, args, client)).

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