From 330b6a8ed5acf907f7576c7bdd9bc4ddae64412e Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Fri, 30 Dec 2022 07:58:40 +1100 Subject: [PATCH] Provide uptime before restarting --- src/commands/restart.ts | 3 ++- src/commands/update.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/restart.ts b/src/commands/restart.ts index 2f35a6f..52178a5 100644 --- a/src/commands/restart.ts +++ b/src/commands/restart.ts @@ -3,7 +3,8 @@ import { TClient } from 'src/client'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech'); - interaction.reply('Restarting...').then(()=>require('node:child_process').exec('pm2 restart Daggerbot')) + client.userLevels.forceSave(); + interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>require('node:child_process').exec('pm2 restart Daggerbot')) }, data: new SlashCommandBuilder() .setName('restart') diff --git a/src/commands/update.ts b/src/commands/update.ts index 7032b55..8cbef34 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -4,7 +4,7 @@ import { exec } from 'node:child_process'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech'); - const msg = await interaction.reply({content: 'Pulling...', fetchReply: true}) + const msg = await interaction.reply({content: 'Pulling from repository...', fetchReply: true}) exec( 'git pull',(err:Error,stdout)=>{ if (err){ @@ -12,7 +12,7 @@ export default { } else if (stdout.includes('Already up to date')){ msg.edit(`Pull aborted:\nUp to date with the repository`) } else { - setTimeout(()=>{msg.edit('Restarting...').then(()=>require('node:child_process').exec('pm2 restart Daggerbot'))},1000) + setTimeout(()=>{msg.edit(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>require('node:child_process').exec('pm2 restart Daggerbot'))},1000) } } )