Hi I'm making a bot for my class and would like some help. I have an Embed and I want it to be deleted and 10 seconds how do I do this? Discord.js 12

Viewed 30

Hi I'm making a bot for my class and would like some help. I have an Embed and I want it to be deleted and 10 seconds how do I do this? Discord.js 12

const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {
  const horarios = new Discord.MessageEmbed()
    .setTitle("") //titulo
    .setURL("") //link do titulo
    .setAuthor("") //autor
    .setDescription(`Olá ${message.author}, aqui está o que você pediu`) //descrição
    .setColor("#006400") //cor em exadecimal
    .setThumbnail("") //imagem pequena na direita
    .setImage("") //imagem grande
    .setFooter("Tenha um bom dia!!!", "https://i.imgur.com/LO44JsA.png") //imagem pequena a baixa junto ao texto
    .addFields({ name: "2ª FEIRA", value: '"CIÊNCIAS DA NATUREZA e LINGUAGENS ```ALMOÇO``` SENAI - ELÉTRICA SENAI – ELÉTRICA', inline: false }, { name: "3ª FEIRA", value: "MATEMÁTICA e CIÊNCIAS HUMANAS ```ALMOÇO``` SENAI - ELÉTRICA SENAI - ELÉTRICA", inline: false }, { name: "4ª FEIRA", value: "CIÊNCIAS DA NATUREZA e LINGUAGENS ```ALMOÇO``` SENAI - ELÉTRICA SENAI - ELÉTRICA", inline: false }, { name: "5ª FEIRA", value: "MATEMÁTICA, CIÊNCIAS HUMANAS e MINDLAB ```ALMOÇO``` SENAI - ELÉTRICA SENAI - ELÉTRICA", inline: false }, { name: "6ª FEIRA", value: "ARTICULAÇÃO ROTA INOVADORA ```ALMOÇO``` SENAI - ELÉTRICA SENAI - ELÉTRICA", inline: false })
    .setTimestamp(); //hora AUTOMATICO

  message.delete().catch((O_o) => {});
  message.channel.send(horarios);
};

module.exports.config = {
  name: "embed",
  description: "example of an Embed.",
  usage: "c!horarios",
  accessableby: "Members",
  aliases: [],
};

1 Answers

When you send the message, you can use the setTimeout function to delete it after a specified amount of time.

// Send the message
message.channel.send(embed message goes here).then(sentMsg => {
  // Delete the sent message after 10000ms
  setTimeout(()=>sentMsg.delete(), 10000);
});
Related