automod: add any_message trigger
This commit is contained in:
parent
b28186aa0a
commit
9ac4e15573
2 changed files with 34 additions and 0 deletions
29
backend/src/plugins/Automod/triggers/anyMessage.ts
Normal file
29
backend/src/plugins/Automod/triggers/anyMessage.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import * as t from "io-ts";
|
||||||
|
import { automodTrigger } from "../helpers";
|
||||||
|
import { verboseChannelMention } from "../../../utils";
|
||||||
|
|
||||||
|
// tslint:disable-next-line:no-empty-interface
|
||||||
|
interface AnyMessageResultType {}
|
||||||
|
|
||||||
|
export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
|
||||||
|
configType: t.type({}),
|
||||||
|
|
||||||
|
defaultConfig: {},
|
||||||
|
|
||||||
|
async match({ pluginData, context, triggerConfig: trigger }) {
|
||||||
|
if (!context.message) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
extra: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
renderMatchInformation({ pluginData, contexts, matchResult }) {
|
||||||
|
const channel = pluginData.guild.channels.get(contexts[0].message!.channel_id);
|
||||||
|
return `Matched message (\`${contexts[0].message!.id}\`) in ${
|
||||||
|
channel ? verboseChannelMention(channel) : "Unknown Channel"
|
||||||
|
}`;
|
||||||
|
},
|
||||||
|
});
|
|
@ -25,8 +25,11 @@ import { UnmuteTrigger } from "./unmute";
|
||||||
import { KickTrigger } from "./kick";
|
import { KickTrigger } from "./kick";
|
||||||
import { BanTrigger } from "./ban";
|
import { BanTrigger } from "./ban";
|
||||||
import { UnbanTrigger } from "./unban";
|
import { UnbanTrigger } from "./unban";
|
||||||
|
import { AnyMessageTrigger } from "./anyMessage";
|
||||||
|
|
||||||
export const availableTriggers: Record<string, AutomodTriggerBlueprint<any, any>> = {
|
export const availableTriggers: Record<string, AutomodTriggerBlueprint<any, any>> = {
|
||||||
|
any_message: AnyMessageTrigger,
|
||||||
|
|
||||||
match_words: MatchWordsTrigger,
|
match_words: MatchWordsTrigger,
|
||||||
match_regex: MatchRegexTrigger,
|
match_regex: MatchRegexTrigger,
|
||||||
match_invites: MatchInvitesTrigger,
|
match_invites: MatchInvitesTrigger,
|
||||||
|
@ -58,6 +61,8 @@ export const availableTriggers: Record<string, AutomodTriggerBlueprint<any, any>
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AvailableTriggers = t.type({
|
export const AvailableTriggers = t.type({
|
||||||
|
any_message: AnyMessageTrigger.configType,
|
||||||
|
|
||||||
match_words: MatchWordsTrigger.configType,
|
match_words: MatchWordsTrigger.configType,
|
||||||
match_regex: MatchRegexTrigger.configType,
|
match_regex: MatchRegexTrigger.configType,
|
||||||
match_invites: MatchInvitesTrigger.configType,
|
match_invites: MatchInvitesTrigger.configType,
|
||||||
|
|
Loading…
Add table
Reference in a new issue