Skip to content

Commit

Permalink
Add pause_invites automod action (#423)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Benricheson101 authored Jan 5, 2024
1 parent 3912523 commit 094e94f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/src/plugins/Automod/actions/availableActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CleanAction } from "./clean";
import { KickAction } from "./kick";
import { LogAction } from "./log";
import { MuteAction } from "./mute";
import { PauseInvitesAction } from "./pauseInvites";
import { RemoveRolesAction } from "./removeRoles";
import { ReplyAction } from "./reply";
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
Expand Down Expand Up @@ -38,6 +39,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
start_thread: StartThreadAction,
archive_thread: ArchiveThreadAction,
change_perms: ChangePermsAction,
pause_invites: PauseInvitesAction,
};

export const AvailableActions = t.type({
Expand All @@ -59,4 +61,5 @@ export const AvailableActions = t.type({
start_thread: StartThreadAction.configType,
archive_thread: ArchiveThreadAction.configType,
change_perms: ChangePermsAction.configType,
pause_invites: PauseInvitesAction.configType,
});
14 changes: 14 additions & 0 deletions backend/src/plugins/Automod/actions/pauseInvites.ts
Original file line number Diff line number Diff line change
@@ -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);
},
});

0 comments on commit 094e94f

Please sign in to comment.