small changes to update command

This commit is contained in:
derpystuff 2023-06-28 15:05:18 +02:00
parent 45ba512b1c
commit ad6f915427

View file

@ -6,6 +6,7 @@ const { icon, highlight } = require('../../../labscore/utils/markdown');
module.exports = { module.exports = {
name: "update", name: "update",
label: "flags",
metadata: { metadata: {
description: 'Fetches latest bot version.', description: 'Fetches latest bot version.',
description_short: 'Bot update', description_short: 'Bot update',
@ -13,16 +14,13 @@ module.exports = {
category: 'dev', category: 'dev',
usage: 'update [-force true]' usage: 'update [-force true]'
}, },
args: [
{ default: false, name: "force", type: "bool", help: "Force update" }
],
onBefore: context => context.user.isClientOwner, onBefore: context => context.user.isClientOwner,
onCancel: ()=>{}, onCancel: ()=>{},
run: async (context, args) => { run: async (context, args) => {
let response = await editOrReply(context, createEmbed("loading", context, "Updating bot...")) let response = await editOrReply(context, createEmbed("loading", context, "Updating bot..."))
try{ try{
const t = Date.now() const t = Date.now()
if(args.force) execSync("git checkout .") if(args.flags.includes('-force') || args.flags.includes('-f')) execSync("git checkout .")
const r = execSync("git pull") const r = execSync("git pull")
if(r.toString().includes("Already up to date.")) return await editOrReply(context, {embeds: [createEmbed("warning", context, "Already up to date.")]}) if(r.toString().includes("Already up to date.")) return await editOrReply(context, {embeds: [createEmbed("warning", context, "Already up to date.")]})
@ -30,7 +28,7 @@ module.exports = {
return await editOrReply(context, { content: `${icon("success_simple")} Updated ${highlight(com[1] + ' -> ' + com[2])} in ${((Date.now() - t) / 1000).toFixed(2)}s`, embeds: []}) return await editOrReply(context, { content: `${icon("success_simple")} Updated ${highlight(com[1] + ' -> ' + com[2])} in ${((Date.now() - t) / 1000).toFixed(2)}s`, embeds: []})
}catch(e){ }catch(e){
console.log(e) console.log(e)
return await editOrReply(context, createEmbed("error", context, "Update failed.")) return await editOrReply(context, createEmbed("error", context, "Update failed. Use -f to force update."))
} }
} }
}; };