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.
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>`;