mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
use moment instead of secondToHms
This commit is contained in:
parent
5c14162431
commit
17c7fbf158
2 changed files with 5 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
const { MessageEmbed } = require('discord.js')
|
||||
const { secondsToHms } = require('../util/secondToHms')
|
||||
const moment = require('moment-timezone')
|
||||
module.exports = {
|
||||
name: 'uptime',
|
||||
alias: [],
|
||||
|
@ -7,13 +7,15 @@ module.exports = {
|
|||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green' }])
|
||||
const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]')
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: time, color: 'green' }])
|
||||
},
|
||||
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
||||
const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]')
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Uptime')
|
||||
.setDescription(`The bot's uptime is ${secondsToHms(Math.floor(performance.now() / 1000))}`)
|
||||
.setDescription(`The bot's uptime is ${time}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
* from codegrepper
|
||||
* @param {Number} d seconds
|
||||
* @return {String} X hour, X minute, X second
|
||||
*/
|
||||
function secondsToHms (d) {
|
||||
d = Number(d)
|
||||
const h = Math.floor(d / 3600)
|
||||
const m = Math.floor(d % 3600 / 60)
|
||||
const s = Math.floor(d % 3600 % 60)
|
||||
const hDisplay = h > 0 ? h + (h === 1 ? ' hour, ' : ' hours, ') : ''
|
||||
const mDisplay = m > 0 ? m + (m === 1 ? ' minute, ' : ' minutes, ') : ''
|
||||
const sDisplay = s > 0 ? s + (s === 1 ? ' second' : ' seconds') : ''
|
||||
return hDisplay + mDisplay + sDisplay
|
||||
}
|
||||
|
||||
module.exports = { secondsToHms }
|
Loading…
Reference in a new issue