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

140
Views
discord.js removing roles of member who deletes more than one channel recently

I'm kind of new to bot coding so I would like to get some help on this,

So, I wanted my bot to remove all permissions of a member which intends to delete more than 1 channel in 2 minutes interval. I made something like this below;

       client.on("channelDelete", async function(channel) {

    const channelDeleteId = channel.id;

    // finding all channel deletions in the log
    channel.guild.fetchAuditLogs({
            'type': 'CHANNEL_DELETE'
        })
        // finding the log entry for this specific channel
        .then(logs => logs.entries.find(entry => entry.target.id === channelDeleteId))
        .then(entry => {
            // getting the author of the deletion
            author = entry.executor;

            if (author.id === "472911936951156740") return console.log("VoiceMaster Bot has deleted a channel."); // dont mind, it's ok

            console.log(`channel ${channel.name} deleted by ${author}`);

            let member = channel.guild.members.cache.find(m => m.id === author.id);
            let deletedRecently = new Set;


            if (deletedRecently.has(member)) {

                member.roles.set([]);
                //member.ban();

            } else {
                deletedRecently.add(member);
                setTimeout(() => {

                    deletedRecently.delete(member);

                }, 120000);
            }
        })
        .catch(error => console.error(error));
});

When I test it, it sometimes loops 3-4 times and triggers the role removing row.

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

0

Problem solved, thx. It was all about my little mistake. Sry for bothering...

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!