-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added uptime command to check when the bot was started
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { SlashCommandBuilder } = require("@discordjs/builders"); | ||
const { embedMessage } = require("../../modules/embedSimple"); | ||
const { msToTime } = require("../../modules/mstoTime"); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("uptime") | ||
.setDescription("Since how long the bot is online"), | ||
async execute(interaction, client) { | ||
await interaction.reply({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`${client.user.username}' Uptime: ${msToTime(client.uptime)}` | ||
), | ||
], | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports.msToTime = (duration) => { | ||
let milliseconds = parseInt((duration % 1000) / 100), | ||
seconds = Math.floor((duration / 1000) % 60), | ||
minutes = Math.floor((duration / (1000 * 60)) % 60), | ||
hours = Math.floor((duration / (1000 * 60 * 60)) % 24); | ||
|
||
hours = hours < 10 ? "0" + hours : hours; | ||
minutes = minutes < 10 ? "0" + minutes : minutes; | ||
seconds = seconds < 10 ? "0" + seconds : seconds; | ||
|
||
return hours + ":" + minutes + ":" + seconds + "." + milliseconds; | ||
}; |