Add pause_invites automod action (#423)

* feat(AutomodPlugin): toggle invite action

* feat: rename and change config shape

* refactor: rename disable_invites to pause_invites

* fix: make options an object, else setting an action to `false` ignores it
This commit is contained in:
Ben Richeson 2024-01-04 20:41:12 -05:00 committed by GitHub
parent 3912523c92
commit 094e94f0f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import { CleanAction } from "./clean";
import { KickAction } from "./kick"; import { KickAction } from "./kick";
import { LogAction } from "./log"; import { LogAction } from "./log";
import { MuteAction } from "./mute"; import { MuteAction } from "./mute";
import { PauseInvitesAction } from "./pauseInvites";
import { RemoveRolesAction } from "./removeRoles"; import { RemoveRolesAction } from "./removeRoles";
import { ReplyAction } from "./reply"; import { ReplyAction } from "./reply";
import { SetAntiraidLevelAction } from "./setAntiraidLevel"; import { SetAntiraidLevelAction } from "./setAntiraidLevel";
@ -38,6 +39,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
start_thread: StartThreadAction, start_thread: StartThreadAction,
archive_thread: ArchiveThreadAction, archive_thread: ArchiveThreadAction,
change_perms: ChangePermsAction, change_perms: ChangePermsAction,
pause_invites: PauseInvitesAction,
}; };
export const AvailableActions = t.type({ export const AvailableActions = t.type({
@ -59,4 +61,5 @@ export const AvailableActions = t.type({
start_thread: StartThreadAction.configType, start_thread: StartThreadAction.configType,
archive_thread: ArchiveThreadAction.configType, archive_thread: ArchiveThreadAction.configType,
change_perms: ChangePermsAction.configType, change_perms: ChangePermsAction.configType,
pause_invites: PauseInvitesAction.configType,
}); });

View file

@ -0,0 +1,14 @@
import * as t from "io-ts";
import { automodAction } from "../helpers";
export const PauseInvitesAction = automodAction({
configType: t.type({
paused: t.boolean,
}),
defaultConfig: {},
async apply({ pluginData, actionConfig }) {
await pluginData.guild.disableInvites(actionConfig.paused);
},
});