discord_bot/commands/uptime.js
SileNce5k c51a4fa976
Pass objects on command.execute
Pass objects instead of using a switch statement.
Now I don't have to restart the bot whenever I add a new command
that needs specific arguments other than 'message'.
2021-03-09 18:50:27 +01:00

30 lines
No EOL
902 B
JavaScript

const parseMS = require('parse-ms')
module.exports = {
name: 'uptime',
description: 'Returns uptime',
execute({message, client}) {
let days = "";
let hours = "";
let minutes = "";
let seconds = "";
let milliseconds = "";
let uptime = parseMS(client.uptime)
if (uptime.days != 0)
days = `${uptime.days} days, `
if (uptime.hours != 0)
hours = `${uptime.hours} hours, `
if (uptime.minutes != 0)
minutes = `${uptime.minutes} minutes, `
if (uptime.seconds != 0)
seconds = `${uptime.seconds} seconds, and `
if (uptime.milliseconds != 0)
milliseconds = `${uptime.milliseconds} milliseconds`
let fullUptime = `This bot has an uptime of ${days}${hours}${minutes}${seconds}${milliseconds}`
message.channel.send(fullUptime)
}
};