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

275
Views
El comando de bloqueo discord.js básico no funciona

Estaba tratando de hacer un comando de bloqueo básico para mi bot discord.js. Le di el código para el comando, lo hice solo utilizable por usuarios con un rol específico y, por último, agregué el código para el bloqueo en sí.

 // lock channel const role = guild.roles.find("name", "👤︱Member"); client.on('message', msg => { if (msg.content === '.lock') { msg.channel.send('Successfully locked the channel.'); if(!message.member.roles.some(r=>["👮︱Moderator", "🔱 ︱Trial Administrator"].includes(r.name))) return message.channel.send(`You dont have the moderator role!`) message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': false }) } });

Si iniciara mi bot, se cerraría automáticamente con este mensaje de error:

ReferenceError: el gremio no está definido

Tengo discord.js v12 si eso ayuda. Si la respuesta es que mi versión de discord.js está desactualizada, ¿al menos puede darme algún consejo sobre el código también?

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

0

Hasta donde yo sé, primero debes crear un gremio, usando algo como:

 const guild = client.guilds.cache.get("YOUR_GUILD_ID");

Y entonces, necesitas usarlo:

 client.on('message', msg => { let guild = message.guild; if (msg.content === '.lock') { msg.channel.send('Successfully locked the channel.'); if(!message.member.roles.some(r=>["👮︱Moderator", "🔱 ︱Trial Administrator"].includes(r.name))) return message.channel.send(`You dont have the moderator role!`) message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': false }) } });

PD No tengo acceso a IDE en este momento, así que no sé si funciona

Además, la mejor manera de permitir que los roles usen el comando es:

 let allowedRole = message.guild.roles.find("name", "Staff"); if (message.member.roles.has(allowedRole.id) { // allowed access to command } else { //aka members who arent staff // not allowed access }
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!