3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-15 06:05:03 +00:00

Initial commit in new repository

This commit is contained in:
Dragory 2018-07-01 03:35:51 +03:00
commit 23c78f2c9c
15 changed files with 4048 additions and 0 deletions

46
src/plugins/BotControl.ts Normal file
View file

@ -0,0 +1,46 @@
import { decorators as d, GlobalPlugin } from "knub";
import * as child_process from "child_process";
import { Message } from "eris";
/**
* A global plugin that allows bot owners to control the bot
*/
export class BotControlPlugin extends GlobalPlugin {
getDefaultOptions() {
return {
config: {
owners: []
}
};
}
isOwner(userId) {
return this.configValue("owners").includes(userId);
}
@d.command("bot_update")
async updateCmd(msg: Message) {
if (!this.isOwner(msg.author.id)) return;
const updateCmd = this.configValue("update_cmd");
if (!updateCmd) {
msg.channel.createMessage("Update command not specified!");
return;
}
msg.channel.createMessage("Updating...");
const updater = child_process.exec(updateCmd, { cwd: process.cwd() });
updater.stderr.on("data", data => {
// tslint:disable-next-line
console.error(data);
});
}
@d.command("bot_reload")
async reloadCmd(msg: Message) {
if (!this.isOwner(msg.author.id)) return;
msg.channel.createMessage("Reloading...");
this.knub.reloadGuild(this.guildId);
}
}