mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Port BotControl
This commit is contained in:
parent
b66e601cef
commit
f500034729
10 changed files with 237 additions and 2 deletions
41
backend/src/plugins/BotControl/BotControlPlugin.ts
Normal file
41
backend/src/plugins/BotControl/BotControlPlugin.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { BotControlPluginType, ConfigSchema } from "./types";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { TextChannel } from "eris";
|
||||
import { sendSuccessMessage } from "../../pluginUtils";
|
||||
import { getActiveReload, resetActiveReload } from "./activeReload";
|
||||
import { ReloadGlobalPluginsCmd } from "./commands/ReloadGlobalPluginsCmd";
|
||||
import { ServersCmd } from "./commands/ServersCmd";
|
||||
import { LeaveServerCmd } from "./commands/LeaveServerCmd";
|
||||
import { ReloadServerCmd } from "./commands/ReloadServerCmd";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
can_use: false,
|
||||
update_cmd: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const BotControlPlugin = zeppelinPlugin<BotControlPluginType>()("bot_control", {
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
commands: [ReloadGlobalPluginsCmd, ServersCmd, LeaveServerCmd, ReloadServerCmd],
|
||||
|
||||
onLoad(pluginData) {
|
||||
pluginData.state.archives = new GuildArchives(0);
|
||||
|
||||
if (getActiveReload()) {
|
||||
const [guildId, channelId] = getActiveReload();
|
||||
resetActiveReload();
|
||||
|
||||
const guild = pluginData.client.guilds.get(guildId);
|
||||
if (guild) {
|
||||
const channel = guild.channels.get(channelId);
|
||||
if (channel instanceof TextChannel) {
|
||||
sendSuccessMessage(pluginData, channel, "Global plugins reloaded!");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue