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..d397bc0 --- /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(stdout); + }); + }; +}; \ No newline at end of file