mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Add antiraid commands
This commit is contained in:
parent
ed757dcbe2
commit
6324b9654b
4 changed files with 62 additions and 0 deletions
|
@ -19,6 +19,9 @@ import { clearOldRecentNicknameChanges } from "./functions/clearOldNicknameChang
|
|||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { ModActionsPlugin } from "../ModActions/ModActionsPlugin";
|
||||
import { MutesPlugin } from "../Mutes/MutesPlugin";
|
||||
import { AntiraidClearCmd } from "./commands/AntiraidClearCmd";
|
||||
import { SetAntiraidCmd } from "./commands/SetAntiraidCmd";
|
||||
import { ViewAntiraidCmd } from "./commands/ViewAntiraidCmd";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -124,6 +127,8 @@ export const AutomodPlugin = zeppelinPlugin<AutomodPluginType>()("automod", {
|
|||
// Messages use message events from SavedMessages, see onLoad below
|
||||
],
|
||||
|
||||
commands: [AntiraidClearCmd, SetAntiraidCmd, ViewAntiraidCmd],
|
||||
|
||||
async onLoad(pluginData) {
|
||||
pluginData.state.queue = new Queue();
|
||||
|
||||
|
|
14
backend/src/plugins/Automod/commands/AntiraidClearCmd.ts
Normal file
14
backend/src/plugins/Automod/commands/AntiraidClearCmd.ts
Normal 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**");
|
||||
},
|
||||
});
|
25
backend/src/plugins/Automod/commands/SetAntiraidCmd.ts
Normal file
25
backend/src/plugins/Automod/commands/SetAntiraidCmd.ts
Normal 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}**`);
|
||||
},
|
||||
});
|
18
backend/src/plugins/Automod/commands/ViewAntiraidCmd.ts
Normal file
18
backend/src/plugins/Automod/commands/ViewAntiraidCmd.ts
Normal 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**`);
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Reference in a new issue