diff --git a/commands/message/dev/pull.js b/commands/message/dev/pull.js new file mode 100644 index 0000000..9279e02 --- /dev/null +++ b/commands/message/dev/pull.js @@ -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.")]}) + } + } +}; \ No newline at end of file diff --git a/labscore/utils/embed.js b/labscore/utils/embed.js index 2f6d5dd..b5ecc5d 100644 --- a/labscore/utils/embed.js +++ b/labscore/utils/embed.js @@ -17,6 +17,14 @@ const embedTypes = Object.freeze({ color: COLORS.embed } }, + "success": (context) => { + return { + author: { + name: `Error` + }, + color: COLORS.success + } + }, "warning": (context) => { return { author: { @@ -61,7 +69,7 @@ module.exports.createEmbed = function(type, context, content){ if(!embedTypes[type]) throw "Invalid Embed Type" if(!content) 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 return emb }