Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

289
Vistas
How could I make the setTimeout(function(){message.delete();} function delete a Discord Message Embed?

I'm getting into javascript, or more specifically discord.js and I've decided to try to make a moderation bot. I created a ban command, and after it bans the user, it sends a message embed showing the info of the ban, such as the reasoning of the ban, the user's tag, etc. I've decided to use the setTimeout function to delete the embed after 5 seconds. But, I can't figure out how to. I know exactly how to use the setTimeout function, it's just that I don't know what to do to delete the embed. Here's my code:

            let kickEmbed = new Discord.MessageEmbed()
            .setTitle('Member Kicked!')
            .setColor("GREEN")
            .addFields(
                {name: `Member:`, value: `${memberTarget}`},
                {name: `Moderator`, value: `${message.author}`},
                {name: `Reason`, value: `${kickReason}`}
            )
            await message.channel.send({embeds: [kickEmbed]})
            setTimeout(function(){
                kickEmbed.delete();
            }, 5000);

The problem is the "kickEmbed.delete();" part. I don't know what to put there. kickEmbed doesn't work, msg doesn't work, message doesn't work either. Here's an error if that helps: 'kickEmbed.delete' is not a function

Can anyone help me solve this?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

setTimeout(function(newArg) {
  newArg.delete();
}, 5000, KickEmbed);

I don't like making posts but first part to solution is understanding what you send to a timeout. If you send no arguments it's a global call and if that updates/changes or is removed errors in code occur so passing the value you intend on usage is optimal here. Second part is discord and its proper usage. GL

about 4 years ago · Juan Pablo Isaza Denunciar

0

This is because you are running it on the MessageEmbed object itself. Make it so you save the sent message to a variable, rather than the embed object

let kickEmbed = new Discord.MessageEmbed()
            .setTitle('Member Kicked!')
            .setColor("GREEN")
            .addFields(
                {name: `Member:`, value: `${memberTarget}`},
                {name: `Moderator`, value: `${message.author}`},
                {name: `Reason`, value: `${kickReason}`}
            )
            let sentMessage = await message.channel.send({embeds: [kickEmbed]})
            setTimeout(function(){
                sentMessage.delete();
            }, 5000)
about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda