Giveaway ends in "active time changes"

Hello, this is my function to show, when giveaways is ends, but its doesnt works, how i can make this? (first actually
No description
No description
9 Replies
Lioness100
Lioness1002y ago
Hi! It would be great if you could provide a bit more information. If I'm understanding correctly, the first picture is what you want to be displayed, and the second is your code? If so, what is being displayed with your current code? I notice you used {long: false} with the ms function, which might be one of your problems. That will turn the "9 hours, 57 minutes, 20 seconds" you showed into "9h57m20s"
caesar
caesar2y ago
Hello, yes. On the first picture show how i want the time show and second picture is my code and what i want? I want automaticly updating time in embed message like we can see 9 hours, 57 minutes, 20 seconds, but this time automaticly changing in embed and i dont know how to make it now, if i type for example 1hour, embed for whole time showing 1 hour not 55minutes 20minutes etc.
Lioness100
Lioness1002y ago
You should use native discord timestamps (for example, <t:1675011000:R>). You can do this by importing Formatters from discord.js, and then:
const time = interaction.options.getString('time');
const timeInMs = ms(time);

// ...

.setDescription(`This giveaway ends: <t:${Math.floor((Date.now() + timeInMs) / 1000)}:R>`)
const time = interaction.options.getString('time');
const timeInMs = ms(time);

// ...

.setDescription(`This giveaway ends: <t:${Math.floor((Date.now() + timeInMs) / 1000)}:R>`)
This will: - get the user input - use the ms function to convert it to ms (for example, "1 second" will become 1000) - create a timestamp by using timestamp syntax (that is: <t:timestamp_in_seconds:R> (the R is for relative) Date.now() is the current time, and if we add timeInMs it will be the time the user wants the giveaway to end at
caesar
caesar2y ago
now its show this
No description
caesar
caesar2y ago
i think its bug
Favna
Favna2y ago
no it's not a bug embed footers cannot have formatted text never could have
Lioness100
Lioness1002y ago
that's not a footer I forgot Math.floor
Favna
Favna2y ago
oh
Lioness100
Lioness1002y ago
Sorry, I updated the code. You have to surround the (Date.now() + timeInMs) / 1000) with Math.floor because Discord only accepts the second count as an integer (Math.floor() rounds down to the nearest integer)
Want results from more Discord servers?
Add your server