• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

198
Vistas
deleting messages if a certain username said it
discordClient.on('messageCreate', async (message) => {

    async function dt() {

        if (message.content.includes('has been timed out for')){

            const user = message.content.split(" ")[1]
            const time = message.content.split(" ")[7]

            if (message.content === `** ${user} has been timed out for ${time} seconds.**`) {
                
                await message.channel.messages.fetch({
                    limit: 20 
                }).then((messages) => {
                    const msg = [];
                    messages.filter(m => m.author.username.toLowerCase() === user.toLowerCase()).forEach(message => msg.push(message))
                    message.channel.bulkDelete(msg).then(() => {
                        console.log('cleared messages')
                    });
                })
            }
    
          
        }
    }

    dt().catch(error)

    });

I made something that makes Twitch chat logs display on Discord, but I am now trying to make it that if a user has been timed out it deletes their messages. The code works fine but if someone typed it in chat it will consider it the same as a timeout so people in chat can delete messages on Discord. Is there any possible way to make it if a certain username did this then you apply the code using webhooks?

enter image description here

The one with the name User Timed Out I got it from /timeout on Twitch but with DancingPotato I just typed the same words as what it would do if it deleted the message without /timeout and it will clear the messages of both.

almost 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda