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

1.5K
Views
La función discord.js v13 permisos.has() no funciona (TypeError: no se pueden leer las propiedades de undefined (leyendo 'has'))

Quiero programar un comando de ban para mi bot de Discord. Tengo esta línea donde el bot debe verificar si un usuario tiene el permiso de Administrador. Si el usuario que debería ser baneado los tiene, el bot no banea al usuario y falla. Cuando trato de ejecutar este comando me sale esto:

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

no entiendo porque Nadie a quien le pregunté pudo ayudarme, no encontré nada en línea, así que espero poder encontrar ayuda aquí.

Mi código:

 const discord = require('discord.js'); const { Permissions } = require('discord.js'); module.exports.run = async (Client, message, args) => { if (!message.member.roles.cache.some(role => role.id == 589850931785498624)) { return message.reply("You don't have the perms."); } const mention = message.mentions.users.first(); if (!mention) { return message.reply('You need to tag a user!'); } if (mention.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)) { return message.reply("You can't ban an Administrator!") } //message.guild.members.ban(mention); } module.exports.help = { name: "ban", aliases: ["b"], }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

"Error de tipo: no se pueden leer las propiedades de undefined (leyendo 'has')" significa que mention.permissions la mención no están undefined . Es porque su variable de mention es un User y solo los miembros del GuildMember tienen permissions .

Otro error es que intenta verificar si role.id es igual a un número/entero, pero los copos de nieve (como 589850931785498624 ) siempre deben ser cadenas , ya que son mayores que MAX_SAFE_INTEGER .

 module.exports.run = async (Client, message, args) => { if (!message.member.roles.cache.some((role) => role.id == '589850931785498624')) return message.reply("You don't have the perms."); const mentionedMember = message.mentions.members.first(); if (!mentionedMember) return message.reply('You need to tag a user!'); if (mentionedMember.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)) return message.reply("You can't ban an Administrator!"); message.guild.members.ban(mentionedMember); };
over 4 years ago · Santiago Trujillo 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!