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

174
Visualizações
Cannot read properties of undefined (reading 'user')
 const unbanUserId = interaction.options.getString('user_id')

  try {
      const getGuildBanList = await interaction.guild.bans.fetch()
      const checkTheUserStated = getGuildBanList.get(unbanUserId).user

    if (checkTheUserStated) {
       await interaction.guild.members.unban(unbanUserId)
        const unBannedEmbed = new MessageEmbed()
        .setColor('PURPLE')
        .setTitle('User unbanned')
        .setDescription(`Successfully unbanned <@!${unbanUserId}>`)

        return interaction.editReply({ embeds: [unBannedEmbed] })
    } else {
        const notBanned = new MessageEmbed()
        .setColor('PURPLE')
        .setDescription(`The stated user is not banned.`)

        return interaction.editReply({ embeds: [notBanned] })
    }
  } catch(e) {
      console.log(e)
  }

I am trying to make it so that when the user isn't banned that it will return a simple embed but it seem just too keep returning Cannot read properties of undefined (reading 'user')

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Can you try using .find() ?

const checkTheUserStated = getGuildBanList.find(user => user.id === unbanUserId.id);

console.log it or try it out, let me know if it works out for you

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