1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 20:40:59 -04:00
Daggerbot-TS/src/commands/update.ts

23 lines
993 B
TypeScript
Raw Normal View History

2022-11-13 19:18:15 -05:00
import Discord from 'discord.js';
import { TClient } from 'src/client';
import { exec } from 'node:child_process';
export default {
async run(client: TClient, message: Discord.Message, args: any){
if (!client.config.eval.whitelist.includes(message.author.id)) return message.reply('You\'re not allowed to use this command')
const msg = await message.reply({content: 'Pulling...', fetchReply: true})
exec(
'git pull',(err:Error,stdout)=>{
if (err){
msg.edit(`Pull failed:\n\`\`\`${err.message}\`\`\``)
} else if (stdout.includes('Already up to date')){
msg.edit(`Pull aborted:\nUp to date with the repository`)
} else {
setTimeout(()=>{msg.edit('Restarting...').then(()=>eval(process.exit(-1)))},1000)
}
}
)
},
name: 'update',
description: 'Pull from repository and restart.',
category: 'bot'
}