diff --git a/config/roles.yml b/config/roles.yml index 558746f..5edc852 100644 --- a/config/roles.yml +++ b/config/roles.yml @@ -15,6 +15,7 @@ MODERATOR: - cosmic.commandGroup.economy - cosmic.command.msg - cosmic.command.memory + - cosmic.command.uptime ADMINISTRATOR: displayName: Administrator inherits: MODERATOR diff --git a/src/commands/commands/utility/uptime.ts b/src/commands/commands/utility/uptime.ts new file mode 100644 index 0000000..8a58867 --- /dev/null +++ b/src/commands/commands/utility/uptime.ts @@ -0,0 +1,24 @@ +import { MicroHandler } from "../../../services/console/MicroHandler"; +import { padNum } from "../../../util/Logger"; +import { Command } from "../../Command"; + +export const uptime = new Command( + "uptime", + ["uptime", "up"], + "get bot uptime bozo", + "uptime", + async (msg, agent) => { + const ms = Math.floor(process.uptime() * 1000); + + const s = ms / 1000; + const m = s / 60; + const h = m / 60; + + const ss = padNum(Math.floor(s) % 60, 2, "0"); + const mm = padNum(Math.floor(m) % 60, 2, "0"); + const hh = padNum(Math.floor(h) % 24, 2, "0"); + const ll = padNum(ms % 1000, 3, "0"); + + return `Uptime: ${hh}:${mm}:${ss}.${ll}`; + } +); diff --git a/src/commands/index.ts b/src/commands/index.ts index bff9427..79c4fd8 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -12,6 +12,7 @@ import { inventory } from "./commands/economy/inventory"; import { color } from "./commands/utility/color"; import { role } from "./commands/utility/role"; import { ic } from "./commands/utility/ic"; +import { uptime } from "./commands/utility/uptime"; export function loadCommands() { // cringe @@ -28,6 +29,16 @@ export function loadCommands() { CommandHandler.addCommandGroup(fun); const utility = new CommandGroup("utility", "🔨 Utility"); - utility.addCommands([math, memory, id, msg, cursor, color, role, ic]); + utility.addCommands([ + math, + memory, + id, + msg, + cursor, + color, + role, + ic, + uptime + ]); CommandHandler.addCommandGroup(utility); } diff --git a/src/permissions/default.ts b/src/permissions/default.ts index d455eab..4570c14 100644 --- a/src/permissions/default.ts +++ b/src/permissions/default.ts @@ -23,7 +23,8 @@ export const defaultConfig = { permissions: [ "cosmic.commandGroup.economy", "cosmic.command.msg", - "cosmic.command.memory" + "cosmic.command.memory", + "cosmic.command.uptime" ] }, ADMINISTRATOR: {