Presence Activity with dynamic data
Hi,
I've seen that with some games when someone is queuing for the matchmaking, it shows a timer that is up to date at the second. For internal use in a server, I want to make something similar with a bot where it would show the current time in 4 specific timezones. How would one go about a task like this? Obviously, one way would be with a
setInterval
running every second but I'm wondering if there's a better way16 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by staffDiscord version:
discord.js@14.11.0
Node version: v18.16.0
if you want it to show the delta or time for anyone, based on their system time, you can use the timestamp styles native to discord
if you want to show the time in these specific timezones for a reason, packages like https://moment.github.io/luxon can help with that - which then makes the question better suited for #other-js-ts instead, since it has nothing to do with discord.js anymore
![mdn](https://cdn.discordapp.com/emojis/957801942573256854.png)
might also be enough, depending on your formatting needs
yeah my main question is should I use
setInterval
to update the presence each second or is there a way to leverage timers like how video games do when you're in a matchmaking
my question is still in regards to Discord API (and more specifically, the high level API from DiscordJS)
but if the answer is setInterval
, I'm fine with that too, just wondering if there are API limits I should be aware ofas said, if you want it to adapt to the viewer's timezone, this is the way to go
I'm pretty certain you cant update presence every second, so this would not be the right approach
I don't want it to adapt to the viewer's timezone
I want the bot to show, as its activity, the time in a specific timezone without adapting to any user's timezone
discord's API supports Rich presence with timers, I know how I could replicate it with setTimeout but it sounds so silly, I'm thinking there has to be a better way, that's what I'm asking here
How does League of Legends do it?
Surely if you can show time elapsed at the second, you can show a clock
You definitely can though, just saying. This guy makes 10 updates per second https://github.com/discord/discord-api-docs/issues/668
if my only way to achieve that is by setting a
startTimestamp
and it would calculate the elapsed time, i have no problem setting that to whatever timestamp represends midnight in the timzone i want to show
my question is how to do this with DiscordJSit's definitely supported by discord API
![No description](https://cdn.answeroverflow.com/1175944625945583636/image.png)
on djs documentation, the only thing I find about Rich Presence are the RichPresenceAssets and it doesn't seem to include the keys I'm interested in https://discord.js.org/docs/packages/discord.js/14.14.1/RichPresenceAssets:Class
does that make sense?