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

386
Views
¿Cómo uso el permiso sobrescribe discord.js?

funcionó en mi último bot, pero ahora las sobrescrituras de permisos no funcionarán en el nuevo bot. Miré la documentación en discord.js simplemente estaba deambulando si alguien podía ayudarme ya que estoy en un callejón sin salida.

código:

 module.exports = { name: 'ticket', description: "creates ticket", async execute(message, args, Discord){ const channel = await message.guild.channels.create(`ticket: ${message.author.tag}`); channel.setParent('967965866035642408'); channel.permissionOverwrites.edit(message.guild.id, { SEND_MESSAGES: false, VIEW_CHANNEL: false, }); channel.permissionOverwrites.edit(message.author, { SEND_MESSAGES: true, VIEW_CHANNEL: true, }); const reactionMessage = await channel.send('Thank you for contacting support!'); try{ await reactionMessage.react("🔒"); await reactionMessage.react("⛔"); }catch(err){ channel.send('Error sending emojis!'); throw err; } const collector = reactionMessage.createReactionCollector( (reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission("ADMINISTRATOR"), {dispose: true } ); collector.on("collect", (reaction, user) => { switch (reaction.emoji.name) { case "🔒": channel.permissionOverwrites.edit(message.author, { SEND_MESSAGES: false }); break; case "⛔": channel.send('deleting this channel in 5 seconds'); setTimeout(() => channel.delete(), 5000); break; } }); message.channel.send(`we will be right with you! ${channel}`).then((msg) => { setTimeout(() => msg.delete(), 7000); setTimeout(() => message.delete(), 3000); }).catch((err) => { throw err; }); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Entonces, la primera parte de esto sería el comando, y separé el comando de la reacción, en caso de que el bot se reinicie o haya un error con el colector, este código sobrevivirá a un reinicio. También probé esto en mi bot y funciona sin problemas.

Archivo comando.js

 module.exports = { name: 'ticket', description: "creates ticket", async execute(message, args, Discord) { const channel = await message.guild.channels.create(`ticket: ${message.author.tag}`, { parent: '967965866035642408', permissionOverwrites: [{ id: message.guild.id, deny: [ 'VIEW_CHANNEL', ], }, { id: message.author, allow: [ 'VIEW_CHANNEL', 'SEND_MESSAGES', ], }], }); const reactionMessage = await channel.send(`Thank you for contacting support! ${message.author}`); // message.author is important for later so make sure it stays in the message somehow. try { await reactionMessage.react("🔒"); await reactionMessage.react("⛔"); } catch (err) { channel.send('Error sending emojis!'); throw err; } message.channel.send(`we will be right with you! ${channel}`).then((msg) => { setTimeout(() => msg.delete(), 7000); setTimeout(() => message.delete(), 3000); }).catch((err) => { throw err; }); }, };

Esta sección iría a su archivo bot.js principal para capturar el agregado de reacción y eliminará automáticamente las reacciones que colocan los miembros que no son administradores.

 client.on('messageReactionAdd', async (messageReaction, user) => { if (user.bot) return; const message = await messageReaction.message.fetch(true); const channel = message.channel; const guild = client.guilds.cache.get(message.guildId); const member = guild.members.cache.get(user.id); if (channel.parent.id === '967965866035642408') { const regex = /\d+/g; const authorID = message.content.match(regex); const originalAuthor = client.users.cache.get(authorID[0]); if (!member.permissions.has("ADMINISTRATOR")) { message.reactions.cache.find(reaction => reaction.emoji.name == messageReaction.emoji.name).users.remove(member.user); return; } else { switch (messageReaction.emoji.name) { case "🔒": channel.permissionOverwrites.edit(originalAuthor, { SEND_MESSAGES: false }); break; case "⛔": channel.send('deleting this channel in 5 seconds'); setTimeout(() => channel.delete(), 5000); break; } } } else { return; } });
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!