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
206module . exports = {
217 name : "uptime" ,
@@ -31,27 +17,14 @@ module.exports = {
3117 * @param {Object } config
3218 */
3319module . 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 : / { u p t i m e } / 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 : / { u p t i m e } / 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 */
6235module . 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 : / { u p t i m e } / 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 : / { u p t i m e } / g, replaceWith : ms ( bot . uptime , { long : true } ) } ,
42+ ] ,
43+ } ) ) ;
7644} ;
0 commit comments