• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

149
Views
Discord js v12 Add rights to a channel if user reacts to a specific message

I have a problem that I can't solve: Every time someone reacts to a specific message a channel gets created, and then the person who reacted first is the only one who has the permissions to see this channel. I set the max amount of reactions to "2", and I want it so that the second person who reacts with the message also gets permissions to see the created channel, but I don't know how to do it. Does somebody has an example? This is what I currently have:

 message.guild.channels.create("Busfahrer", {
                    type: "text",
                    parent: category,
                    permissionOverwrites: [
                        {
                            id: message.guild.id,
                            allow: ['SEND_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY'],
                            deny: ['VIEW_CHANNEL'],                                
                        }
                    ]
                })
almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Keep track of who reacts first and second and only give it to the second person:

const collector = reactionMessage2p.createReactionCollector(filter2p, {max: 2, time: 20000, errors: ['time'] })
let reactedUsers = []

collector.on("collect", (reaction, user) => {
  reactedUsers.push(user.id)
})

collector.on("end", async () => {
  let targetUser = reactedUsers[1]
  // channel is the channel you create
  channel.updateOverwrite(targetUser, {
    VIEW_CHANNEL: true
  })
})

I got some of this code from your other question

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error