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

157
Visualizações
How do I add timer in my bot like the other giveaway bots?

What I want is a timer in my bot giveaway embed message which like works when the bot is off and the timer still updates itself without showing that the message was edited.

So I am just showing what I have done in embed:

   const embed = new MessageEmbed();
   embed.setAuthor({
        name: `${message.guild.name} GiveAways!`,
        iconURL: `${message.guild.iconURL({ dynamic: true })}`
   });
   embed.setThumbnail(`${message.guild.iconURL({ dynamic: true })}`);
   embed.setTitle(`${title.toUpperCase()}`);
   embed.setColor("BLURPLE");
   embed.setDescription(
      `
      **React With 🎉 To Enter!**
      **Ends In: ${time} ${}!**
      **Hosted By: ${message.author}!**
      `
   );
   embed.setFooter({
       text: `${winnerCount.toString().slice(0, -1)} Winners | Ends`
   });
   embed.setTimestamp(Date.now() + ms(duration));

   const sentGiveaway = await channel.send({
      content: "||@everyone|| **🥳   GIVEAWAY   🥳**",
      embeds: [embed]
   });
   sentGiveaway.react("🎉");

title - This provide the title for the giveaway. time - This coverts the duration entered by user to the full name. E.g: 4d => 4 Days. winnerCount - This provide how many winners will win the giveaway. duration - This takes the argument from user. Date.now + ms(duration) - This provide the exact time when the giveaway will end.

What is my embed doing - this is my giveaway embed where I am providing the the duration and stuff, The embed.setTimestamp() does not do what I want, it jus tells when will the giveaway end. (I am not providing full code cause some people told me to not to paste full code)

What I want - I want that in the description next to the variable time, I want a automatic time update which people can send and the bots can send but I don't know how to do that, I have seen many bots send the timer in there messages.

This the thing I am talking about, check the highlighted thing you will see that this thing update itself when the bot is switched off. (Click the link to see the image)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Refer to unix timestamps.

They use seconds instead of milliseconds, so you will need to do the necessary division when working with milliseconds (divide by 1000 & Math.floor() it)

For example:

const timestamp = new Date().getTime() + 600000 // (in 10 minutes)
const timestampInSecs = Math.floor(timestamp / 1000); // Necessary division

// Choose appropriate formatting option - the one GiveawayBot uses is R
const timestampString = `<t:${timestampInSecs}:R>`;
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