From 2b55bcdc4d8bd50b9cffcea3d4809b8efc7b6301 Mon Sep 17 00:00:00 2001 From: Lucaslah Date: Thu, 16 Dec 2021 13:44:41 +1300 Subject: [PATCH 1/2] Add Update command --- server/src/API/API.ts | 8 +++--- server/src/commands/private/Update.ts | 38 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 server/src/commands/private/Update.ts diff --git a/server/src/API/API.ts b/server/src/API/API.ts index 35292a6..0c8c145 100644 --- a/server/src/API/API.ts +++ b/server/src/API/API.ts @@ -22,10 +22,10 @@ export default class API { public start(): void { this.server = express(); this.server.use(express.json()); - this.server.use(cors({ - credentials: true, - origin: ["https://matrixdev.xyz", "https://stone.cssudii.tk"] - })); + //this.server.use(cors({ + // credentials: true, + //origin: ["https://matrixdev.xyz", "https://stone.cssudii.tk"] + //})); new GuildRouter(this.server, this.client); new MemberRouter(this.server, this.client); diff --git a/server/src/commands/private/Update.ts b/server/src/commands/private/Update.ts new file mode 100644 index 0000000..907d86a --- /dev/null +++ b/server/src/commands/private/Update.ts @@ -0,0 +1,38 @@ +import { Message } from "discord.js"; + +import Command from "../../structures/Command"; +import MatrixClient from "../../client/Client"; +import { exec } from "child_process"; + +import { configOptions } from "../../client/Config"; + +export default class UpdateCommand extends Command { + constructor() { + super("update", { + categoryID: "Private", + channel: "all", + cooldown: 5, + description: "Updates the bot from github", + disabled: false, + examples: ["update"], + exceptions: { + ignoreCooldown: configOptions.owners, + ignorePermissions: configOptions.owners + }, + permissions: { + clientPermissions: ["SEND_MESSAGES", "USE_EXTERNAL_EMOJIS", "EMBED_LINKS", "MANAGE_MESSAGES"], + userPermissions: ["SEND_MESSAGES"] + }, + ownerOnly: true, + usage: "update" + }); + }; + + public async exec(client: MatrixClient, message: Message, args: string[], Discord: typeof import("discord.js")): Promise { + exec("cd .. && cd .. && cd .. && cd .. && git pull", (error, stdout, stderr) => { + // Chnage messages to embeds if you want + if (error) return message.channel.send("Failed to update from github!"); + return message.channel.send("Updated code!"); + }); + }; +}; \ No newline at end of file From cf526c99c89393764643de9f514acba39f2a41c7 Mon Sep 17 00:00:00 2001 From: Lucaslah Date: Thu, 16 Dec 2021 16:07:37 +1300 Subject: [PATCH 2/2] update update command --- server/src/commands/private/Update.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/commands/private/Update.ts b/server/src/commands/private/Update.ts index 907d86a..d397bc0 100644 --- a/server/src/commands/private/Update.ts +++ b/server/src/commands/private/Update.ts @@ -32,7 +32,7 @@ export default class UpdateCommand extends Command { exec("cd .. && cd .. && cd .. && cd .. && git pull", (error, stdout, stderr) => { // Chnage messages to embeds if you want if (error) return message.channel.send("Failed to update from github!"); - return message.channel.send("Updated code!"); + return message.channel.send(stdout); }); }; }; \ No newline at end of file