Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda