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

356
Views
Cómo bloquear y desbloquear un canal usando discord.js v13.4

Así que probé muchas formas de bloquear un canal a un rol específico, este es uno de mis códigos de intento:

Bloqueando el canal

 const Command = require("../structures/Command.js"); const { Permissions } = require('discord.js'); module.exports = new Command({ name: "lock", description: "lock the channel that the command is executed", async run(message, args, client) { if (message.author.bot) return; if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){ let role = message.guild.roles.cache(r => r.id === "895151537511362600"); role.overwritePermissions(UserResolvable, { VIEW_CHANNEL: true, SEND_MESSAGES: false, READ_MESSAGE_HISTORY: true, ATTACH_FILES: false }); } else message.reply(`why do you want to use a mod command when you're not a mod`) } });

Desbloqueo:

 const Command = require("../structures/Command.js"); const { Permissions } = require('discord.js'); module.exports = new Command({ name: "unlock", description: "unlock the channel that the command is executed", async run(message, args, client) { if (message.author.bot) return; if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){ let role = message.guild.roles.cache(r => r.id === "895151537511362600"); role.overwritePermissions(UserResolvable, { VIEW_CHANNEL: true, SEND_MESSAGES: true, READ_MESSAGE_HISTORY: true, ATTACH_FILES: true }); } else message.reply(`why do you want to use a mod command when you're not a mod`) } });

No funcionó, también devolvió un error que dice que UserResolvable is not defined . También probé este método y todavía no funcionó.

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

0

De acuerdo con los documentos , usa channel.permissionOverwrites.edit()

Entonces su código de bloqueo se vería así:

 message.channel.permissionOverwrites.edit(message.guild.everyone.id, { VIEW_CHANNEL: false, SEND_MESSAGES: false, READ_MESSAGE_HISTORY: false, ATTACH_FILES: false }); message.channel.permissionOverwrites.edit("ROLE_ID", { VIEW_CHANNEL: true, SEND_MESSAGES: true, READ_MESSAGE_HISTORY: true, ATTACH_FILES: true });

Y luego, para el comando de desbloqueo, simplemente cambie los valores de permiso.

about 4 years ago · Juan Pablo Isaza Report

0

Para bloquear el uso como este

 channel.permissionOverwrites.edit(channel.guild.roles.everyone, { SEND_MESSAGES: false }).catch((e) => { console.error(e) })
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!