Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!