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

174
Vistas
TypeError: Cannot read properties of undefined (reading 'cache') discord.js V13 command interaction

I get this error when the command executed the command is an unmute command and my handler is a slash command

when i set the the member as member type in options its work fine but i want it with ID if anyone have a solutions and thx

        if(target.roles.cache.has(muterole)) {
                        ^

TypeError: Cannot read properties of undefined (reading 'cache')

this the command :

const { MessageEmbed, CommandInteraction } = require("discord.js");


module.exports = {
    name: "unmute",
    description: "Unmute a Member",
    permission: "MANAGE_MESSAGES",
    options: [
        {
            name: "member",
            description: "Member ID",
            required: true,
            type: "STRING"
        },
        {
            name: "reason",
            description: "provide unmute reason",
            required: true,
            type: "STRING"
        }
    ],
    /**
     * 
     * @param {CommandInteraction} interaction 
     */
    async execute(interaction) {
        const { guild, channel, member, options } = interaction;

        const target = options.getString("member");
        const reason = options.getString("reason");
        const logchannel = guild.channels.cache.get("877754209016086588");
        const muterole = guild.roles.cache.get("944200095040167946");
        console.log(target);
        const logembed = new MessageEmbed()
        .setColor("AQUA")
        .setAuthor({ name: `${member.user.tag}`, iconURL: `${member.user.avatarURL({ dynamic: true, size: 512 })}` })
        .setDescription(`
${target} got unmuted 
        by : ${member}
        reason : ${reason}
        `)
        .setTimestamp();
        const response = new MessageEmbed()
        .setDescription(`
${target} unmuted
        `);
        if(target.roles.cache.has(muterole)) {
            await target.roles.remove(muterole);
            await interaction.reply({embeds: [response], ephemeral: true});
            await logchannel.send({
                    content: `${member}`,
                    embeds: [logembed]
            });
        } else {
            await interaction.reply({content: `${target} is not muted`, ephemeral: true});
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  • USER type supports Snowflake Ids, User Mentions & Member Mentions.
  • You can add type: "USER" and use
const member = interaction.options.getMember("target"); // for a GuildMember
const user = interaction.options.getUser("target"); // for a User
  • Once again, it supports user IDs and mentions.
  • Using a string for fetching a member/user isn't efficient because if the ID provided is invalid, the bot returns null and might lead to a crash.
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