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 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 }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 } } })