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

378
Views
TypeError: role.setPermissions no es una función aunque TypeScript dice que lo es

Estaba creando un comando que recorre todos los roles en un servidor y elimina/agrega un permiso seleccionado (si es posible). Al pasar el cursor sobre él, se muestra la descripción de la función.

 async execute(client, msg, args, cooldowns, guildForPre, prefix) { if(msg.member.permissions.has("MANAGE_ROLES")) { let roles = (await msg.guild.roles.fetch()).cache; let highPos = getRoleByMention(args[1], msg.guild)?.position || msg.guild.roles.highest.position let lowPos = getRoleByMention(args[2], msg.guild)?.position || msg.guild.roles.everyone.position roles = roles.filter(r => r.permissions.has(args[0])) roles = roles.filter(r => r.position <= highPos && r.position >= lowPos) let replaced = '' for await (const [, role] of roles) { if(role.position >= msg.guild.me.roles.highest.position || role.position >= msg.member.roles.highest.position) continue; await role.setPermissions(role.permissions.remove(args[0])) (replaced.length) ? replaced += `, ${role.name}` : replaced += `${role.name}` } msg.channel.send("Replaced roles: " + replaced) } }

función getRoleByMention :

 function getRoleByMention(mention, guild) { const id = mention.slice(3, mention.length-1) return guild.roles.cache.get(id) }

Los argumentos de mi controlador de comandos se ingresaron correctamente y el comando ingresado es el siguiente:

m.removeRolePerm MANAGE_MESSAGES @Dyno @Dyno

¿Es porque son el mismo papel? Los documentos dicen que es una función válida. Estoy usando v12.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es en realidad la declaración después. Esto se debe a la falta de punto y coma. Agregar un punto y coma debería hacer que funcione. Cambiarlo a esto eliminará el error y hará que funcione también

 await role.setPermissions(role.permissions.remove(args[0])) if (replaced.length) replaced += `, ${role.name}` else replaced += `${role.name}`
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!