automod: add any_message trigger

This commit is contained in:
Dragory 2021-04-02 17:57:04 +03:00
parent b28186aa0a
commit 9ac4e15573
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 34 additions and 0 deletions

View 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"
}`;
},
});

View file

@ -25,8 +25,11 @@ import { UnmuteTrigger } from "./unmute";
import { KickTrigger } from "./kick";
import { BanTrigger } from "./ban";
import { UnbanTrigger } from "./unban";
import { AnyMessageTrigger } from "./anyMessage";
export const availableTriggers: Record<string, AutomodTriggerBlueprint<any, any>> = {
any_message: AnyMessageTrigger,
match_words: MatchWordsTrigger,
match_regex: MatchRegexTrigger,
match_invites: MatchInvitesTrigger,
@ -58,6 +61,8 @@ export const availableTriggers: Record<string, AutomodTriggerBlueprint<any, any>
};
export const AvailableTriggers = t.type({
any_message: AnyMessageTrigger.configType,
match_words: MatchWordsTrigger.configType,
match_regex: MatchRegexTrigger.configType,
match_invites: MatchInvitesTrigger.configType,