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

263
Vistas
Cannot read properties of undefined (reading 'fetchBans')

Im trying to make a command with in my Discord bot to make unban a person. When I finnished the code I got an error. The error is Cannot read properties of undefined (reading 'fetchBans'). The code I use to make it is

message.guild.cache.fetchBans().then(async bans => {
            if (bans.size === 0) return message.channel.send("No one is banned on the server!")
            let bannedUser = bans.find(ban => ban.user.id == userID)
            if (!bannedUser) return message.channel.send("This user isn't banned!")
            await message.guild.members.unban(bannedUser.user, reason).catch(err => {
                return message.channel.send("Something went wrong!")
            }).then(() => {
                let embed = new MessageEmbed()
                    .setColor("GREEN")
                    .setTitle(`Member unbanned!`)
                    .setDescription("")
                    .setTimestamp()
                    .setFooter(this.client.user.username)

            embed.addField(`member = ${target.username}`, `reason = ${reason}`, false)


            message.channel.send({embeds: [embed]});

            if (row[0].logs_channel != null) this.client.channels.cache.get(row[0].logs_channel).send({embeds: [embed]})

            message.delete()
        })

The line where it goes wrong is this line:

 message.guild.cache.fetchBans().then(async bans => {

When I run this command it will give the error. I also tried to do something else. The code i tried else for that line is:

message.guild.fetchBans().then(async bans => {

This line also gave an error that says: TypeError: message.guild.fetchBans is not a function.

I don't know what i can do about this. I hope somebody can help me.

Node.js version: 16.9.1 discord.js version: 13.1.0

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

According to the documentation there is no fetchBans on Guild. Maybe you're looking for message.guild.bans.fetch().

It's also worth noting that message.guild is nullable - if the message was a direct message (not sent in a guild) it will be null.

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