3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-12 04:55:01 +00:00

Add antiraid commands

This commit is contained in:
Dragory 2020-07-30 00:58:34 +03:00
parent ed757dcbe2
commit 6324b9654b
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,14 @@
import { command } from "knub";
import { AutomodPluginType } from "../types";
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
import { sendSuccessMessage } from "../../../pluginUtils";
export const AntiraidClearCmd = command<AutomodPluginType>()({
trigger: ["antiraid clear", "antiraid reset", "antiraid none", "antiraid off"],
permission: "can_set_antiraid",
async run({ pluginData, message }) {
await setAntiraidLevel(pluginData, null, message.author);
sendSuccessMessage(pluginData, message.channel, "Anti-raid turned **off**");
},
});

View file

@ -0,0 +1,25 @@
import { command } from "knub";
import { AutomodPluginType } from "../types";
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
export const SetAntiraidCmd = command<AutomodPluginType>()({
trigger: "antiraid",
permission: "can_set_antiraid",
signature: {
level: ct.string(),
},
async run({ pluginData, message, args }) {
const config = pluginData.config.get();
if (!config.antiraid_levels.includes(args.level)) {
sendErrorMessage(pluginData, message.channel, "Unknown anti-raid level");
return;
}
await setAntiraidLevel(pluginData, args.level, message.author);
sendSuccessMessage(pluginData, message.channel, `Anti-raid level set to **${args.level}**`);
},
});

View file

@ -0,0 +1,18 @@
import { command } from "knub";
import { AutomodPluginType } from "../types";
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
export const ViewAntiraidCmd = command<AutomodPluginType>()({
trigger: "antiraid",
permission: "can_view_antiraid",
async run({ pluginData, message, args }) {
if (pluginData.state.cachedAntiraidLevel) {
message.channel.createMessage(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
} else {
message.channel.createMessage(`Anti-raid is **off**`);
}
},
});