Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

335
Vistas
Discord js 13 botón editar permiso canal

Cuando una persona envía mi comando, se crea un canal al que solo ellos tienen acceso. Además, al crear un canal, se envía un mensaje con el botón "aceptar", cuando otra persona hace clic en el botón, se deben agregar sus derechos en el canal creado. Puedo agregar derechos, pero cuando llega más de un mensaje con un botón a un canal especial, la persona que hizo clic en el botón se agrega a todos los canales creados

Un ejemplo de cómo funcionaUn ejemplo de cómo funciona

 let myreportChannel = '' await interaction.guild.channels.create(channelNameMy, { type: 'text', parent: `${categoryTiket}`, permissionOverwrites: [ { id: `${permUser}`, // permUser - who sent the command allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES'] }, { id: `${evryOneRolle}`, deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] }, ] }) //Prvivate embed .then(async reportChannel => { const exampleEmbed = new MessageEmbed() .setDescription(`Reported: <@${tagBan.id}>\nReason: ${reason}\ntiket: <#${reportChannel.id}>`) .setColor("#2F3136") .setImage(`${settings.reportgif}`) myreportChannel = reportChannel.id // save new channel id await interaction.reply({embeds: [exampleEmbed], ephemeral: true}) //Report embed const reportEmbed = new MessageEmbed() .setDescription(`Intruder: ${tagBan}\nReason: ${reason}`) .setColor("#2F3136") .setImage(`${settings.reportgif}`) await client.channels.cache.get(`${reportChannel.id}`).send({ embeds: [reportEmbed] }) }) client.on('interactionCreate', async interaction => { if (interaction.isButton()) { if (interaction.customId.includes(`acceptB`)) { const editEmbRep = new MessageEmbed() .setDescription(`Author: <@${interaction.user.id}>\nIntruder: <@${tagBan.id}>\nStatus: ${dmStatusAc}\nTiket: <#${myreportChannel}>`) .setColor("#2F3136") .setImage(`${settings.reportgif}`) interaction.message.edit({ content: 'updated text', embeds: [editEmbRep], components: [] }) let channelx = interaction.guild.channels.cache.get(myreportChannel) // set channel by id if (channelx) { channelx.permissionOverwrites.edit(interaction.user.id, { VIEW_CHANNEL: true, SEND_MESSAGES: true, ATTACH_FILES: true, READ_MESSAGE_HISTORY: true }) //edit permision channel. add the permission of the user who clicked on the "accept" button }
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Así que ajusté el código anterior e hice algunas notas en el camino, pero esto debería funcionar como se esperaba. Dividí el comando de presionar el botón.

 const reportChannel = await interaction.guild.channels.create(channelNameMy, { type: 'text', parent: `${categoryTiket}`, permissionOverwrites: [{ id: `${permUser}`, // permUser - who sent the command allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES'] }, { id: `${evryOneRolle}`, deny: ['VIEW_CHANNEL'] //denying view channel will stop all other ones from working too }, ] }) //Prvivate embed const exampleEmbed = new MessageEmbed() .setDescription(`Reported: <@${tagBan.id}>\nReason: ${reason}\nticket: <#${reportChannel.id}>`) .setColor("#2F3136") .setImage(`${settings.reportgif}`) interaction.reply({ embeds: [exampleEmbed], ephemeral: true }) //Report embed const reportEmbed = new MessageEmbed() .setDescription(`Intruder: ${tagBan}\nReason: ${reason}\nticket:<#${reportChannel.id}>`) .setColor("#2F3136") .setImage(`${settings.reportgif}`) .setFooter({ text: `${reportChannel.id}` // I added the channel ID here again (critical part of the code to not change }) // adds the new channel id to the footer to be used later when someone clicks the accept button const acceptButton = new MessageActionRow() .addComponents( new MessageButton() .setCustomId(`acceptB`) .setLabel('Accept') .setStyle('SUCCESS') .setEmoji('✅') ) client.channels.cache.get(reportChannel.id).send({ embeds: [reportEmbed], components: [acceptButton] })
 client.on('interactionCreate', async interaction => { if (interaction.isButton()) { if (interaction.customId.includes(`acceptB`)) { // when someone clicks the accept button it grabs the embed const oldEmbed = interaction.message.embeds[0] // adds a line to that embed const editEmbRep = new MessageEmbed() .addField('Status:', `${dmStatusAc}`) // updates the embed and removes the button interaction.message.edit({ embeds: [editEmbRep], components: [] }) // finds the channel using the channel id placed in the footer earlier const channelx = interaction.guild.channels.cache.get(oldEmbed.footer.text) channelx.permissionOverwrites.edit(interaction.user.id, { VIEW_CHANNEL: true, SEND_MESSAGES: true, ATTACH_FILES: true, READ_MESSAGE_HISTORY: true }) // adds them to the channel } } })
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda