mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Provide uptime before restarting
This commit is contained in:
parent
490e0b7eef
commit
330b6a8ed5
@ -3,7 +3,8 @@ import { TClient } from 'src/client';
|
|||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
|
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()
|
data: new SlashCommandBuilder()
|
||||||
.setName('restart')
|
.setName('restart')
|
||||||
|
@ -4,7 +4,7 @@ import { exec } from 'node:child_process';
|
|||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
|
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(
|
exec(
|
||||||
'git pull',(err:Error,stdout)=>{
|
'git pull',(err:Error,stdout)=>{
|
||||||
if (err){
|
if (err){
|
||||||
@ -12,7 +12,7 @@ export default {
|
|||||||
} else if (stdout.includes('Already up to date')){
|
} else if (stdout.includes('Already up to date')){
|
||||||
msg.edit(`Pull aborted:\nUp to date with the repository`)
|
msg.edit(`Pull aborted:\nUp to date with the repository`)
|
||||||
} else {
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user