2022-11-16 13:53:42 -05:00
|
|
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
2022-11-13 19:18:15 -05:00
|
|
|
import { TClient } from 'src/client';
|
|
|
|
import { exec } from 'node:child_process';
|
|
|
|
export default {
|
2022-11-16 13:53:42 -05:00
|
|
|
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})
|
2022-11-13 19:18:15 -05:00
|
|
|
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 {
|
2022-11-17 12:58:19 -05:00
|
|
|
setTimeout(()=>{msg.edit('Restarting...').then(()=>require('node:child_process').exec('pm2 restart Daggerbot'))},1000)
|
2022-11-13 19:18:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
2022-11-16 13:53:42 -05:00
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName('update')
|
|
|
|
.setDescription('Pull from repository and restart')
|
2022-11-13 19:18:15 -05:00
|
|
|
}
|