-
Notifications
You must be signed in to change notification settings - Fork 1
add uptime to playercount command #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
AlexProgrammerDE
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. The build is failing. Please address the issues
AlexProgrammerDE
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except that one thing. looks mergeable
| let uptimeStr = ""; | ||
| if (data.uptime.serverStartUnix) { | ||
| const diff = Math.floor(Date.now() / 1000 - data.uptime.serverStartUnix); | ||
| const days = Math.floor(diff / 86400); | ||
| const hours = Math.floor((diff % 86400) / 3600); | ||
| const minutes = Math.floor((diff % 3600) / 60); | ||
| const seconds = diff % 60; | ||
| const parts = []; | ||
| if (days > 0) parts.push(`${days}d`); | ||
| if (hours > 0) parts.push(`${hours}h`); | ||
| if (minutes > 0) parts.push(`${minutes}m`); | ||
| if (seconds > 0) parts.push(`${seconds}s`); | ||
| uptimeStr = parts.join(" "); | ||
| } else if (data.uptime.currentUptimeHours) { | ||
| const totalSeconds = Math.floor(data.uptime.currentUptimeHours * 3600); | ||
| const days = Math.floor(totalSeconds / 86400); | ||
| const hours = Math.floor((totalSeconds % 86400) / 3600); | ||
| const minutes = Math.floor((totalSeconds % 3600) / 60); | ||
| const seconds = totalSeconds % 60; | ||
| const parts = []; | ||
| if (days > 0) parts.push(`${days}d`); | ||
| if (hours > 0) parts.push(`${hours}h`); | ||
| if (minutes > 0) parts.push(`${minutes}m`); | ||
| if (seconds > 0) parts.push(`${seconds}s`); | ||
| uptimeStr = parts.join(" "); | ||
| } else { | ||
| await interaction.reply(`The server is currently down.`); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there has got to be a better way to do this rather than to duplicate it twice.
maybe use some library
maybe use a shared function
preferably a library
No description provided.