Skip to content

Commit 1d8f1c0

Browse files
committed
Changed style and few methods in uptime command
1 parent 39a7fc6 commit 1d8f1c0

File tree

2 files changed

+20
-52
lines changed

2 files changed

+20
-52
lines changed

Commands/General/uptime.js

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
const Discord = require("discord.js"),
1+
const Discord = require("discord.js"), ms = require("ms"),
22
Utils = require("../../Modules/Utils"),
3-
{ lang, config, commands } = require("../../index"),
4-
{ SlashCommandBuilder } = require("@discordjs/builders"),
5-
moment = require("moment");
6-
7-
// Receive client uptime in miliseconds
8-
// and break the number into days, hours, minutes and seconds
9-
const duration = (ms) => {
10-
const sec = Math.floor((ms / 1000) % 60).toString();
11-
const min = Math.floor((ms / (1000 * 60)) % 60).toString();
12-
const hrs = Math.floor((ms / (1000 * 60 * 60)) % 60).toString();
13-
const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString();
14-
return days.padStart(1, "0") + " " + "days" + " " +
15-
hrs.padStart(2, "0") + " " + "hours" + " " +
16-
min.padStart(2, "0") + " " + "minutes" + " " +
17-
sec.padStart(2, "0") + " " + "seconds" + " ";
18-
};
3+
{ lang, config, commands } = require("../../index");
4+
195

206
module.exports = {
217
name: "uptime",
@@ -31,27 +17,14 @@ module.exports = {
3117
* @param {Object} config
3218
*/
3319
module.exports.run = async (bot, message, args, config) => {
34-
message.channel
35-
.send({
36-
embeds: [
37-
{
38-
title: "Fetching uptime...",
39-
},
40-
],
41-
})
42-
.then(async (msg) => {
43-
msg.delete();
44-
msg.channel.send(
45-
Utils.setupMessage({
46-
configPath: lang.General.Uptime,
47-
variables: [
48-
...Utils.userVariables(message.member),
49-
...Utils.botVariables(bot),
50-
{ searchFor: /{uptime}/g, replaceWith: duration(bot.uptime) },
51-
],
52-
})
53-
);
54-
});
20+
message.reply(Utils.setupMessage({
21+
configPath: lang.General.Uptime,
22+
variables: [
23+
...Utils.userVariables(message.member),
24+
...Utils.botVariables(bot),
25+
{ searchFor: /{uptime}/g, replaceWith: ms(bot.uptime, { long: true }) },
26+
],
27+
}));
5528
};
5629

5730
/**
@@ -60,17 +33,12 @@ module.exports.run = async (bot, message, args, config) => {
6033
* @param {Discord.Interaction} interaction
6134
*/
6235
module.exports.runSlash = async (bot, interaction) => {
63-
interaction.reply(
64-
Utils.setupMessage(
65-
{
66-
configPath: lang.General.Uptime,
67-
variables: [
68-
...Utils.userVariables(interaction.member),
69-
...Utils.botVariables(bot),
70-
{ searchFor: /{uptime}/g, replaceWith: duration(bot.uptime) },
71-
],
72-
},
73-
true
74-
)
75-
);
36+
interaction.reply(Utils.setupMessage({
37+
configPath: lang.General.Uptime,
38+
variables: [
39+
...Utils.userVariables(interaction.member),
40+
...Utils.botVariables(bot),
41+
{ searchFor: /{uptime}/g, replaceWith: ms(bot.uptime, { long: true }) },
42+
],
43+
}));
7644
};

lang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ General:
2828
- Author: "{bot-tag}'s Uptime"
2929
AuthorIcon: "{bot-pfp}"
3030
Description: |-
31-
**Current Uptime**: {uptime}
31+
> **Current Uptime**: {uptime}
3232
Footer: "{user-tag}"
3333
FooterIcon: "{user-pfp}"
3434
Timestamp: true

0 commit comments

Comments
 (0)