Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!