mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 22:23:03 -04:00
update command :)
This commit is contained in:
parent
a5e1dd506c
commit
cf33bb87bb
2 changed files with 41 additions and 1 deletions
32
commands/message/dev/pull.js
Normal file
32
commands/message/dev/pull.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const { Constants, Utils } = require("detritus-client");
|
||||||
|
const Permissions = Constants.Permissions;
|
||||||
|
|
||||||
|
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
|
|
||||||
|
const { execSync } = require("child_process")
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "update",
|
||||||
|
metadata: {
|
||||||
|
description: 'update bot',
|
||||||
|
examples: ['update'],
|
||||||
|
category: 'dev',
|
||||||
|
usage: 'update'
|
||||||
|
},
|
||||||
|
onBefore: context => context.user.isClientOwner,
|
||||||
|
onCancel: context =>
|
||||||
|
context.reply(
|
||||||
|
`${context.user.mention}, you are lacking the permission \`BOT_OWNER\`.`
|
||||||
|
),
|
||||||
|
run: async (context, args) => {
|
||||||
|
await context.triggerTyping();
|
||||||
|
let response = editOrReply(context, createEmbed("loading", context, "Updating bot..."))
|
||||||
|
try{
|
||||||
|
execSync("git pull")
|
||||||
|
return await response.edit({embeds: [createEmbed("success", context, "Update complete.")]})
|
||||||
|
}catch(e){
|
||||||
|
return await response.edit({embeds: [createEmbed("error", context, "Update failed.")]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -17,6 +17,14 @@ const embedTypes = Object.freeze({
|
||||||
color: COLORS.embed
|
color: COLORS.embed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"success": (context) => {
|
||||||
|
return {
|
||||||
|
author: {
|
||||||
|
name: `Error`
|
||||||
|
},
|
||||||
|
color: COLORS.success
|
||||||
|
}
|
||||||
|
},
|
||||||
"warning": (context) => {
|
"warning": (context) => {
|
||||||
return {
|
return {
|
||||||
author: {
|
author: {
|
||||||
|
@ -61,7 +69,7 @@ module.exports.createEmbed = function(type, context, content){
|
||||||
if(!embedTypes[type]) throw "Invalid Embed Type"
|
if(!embedTypes[type]) throw "Invalid Embed Type"
|
||||||
if(!content) embedTypes[type](context)
|
if(!content) embedTypes[type](context)
|
||||||
let emb = embedTypes[type](context)
|
let emb = embedTypes[type](context)
|
||||||
if(["warning","error","loading"].includes(type)){
|
if(["success","warning","error","loading"].includes(type)){
|
||||||
emb.author.name = content
|
emb.author.name = content
|
||||||
return emb
|
return emb
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue