3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

automod: update match summaries for match_* triggers

This commit is contained in:
Dragory 2020-07-29 22:42:17 +03:00
parent 06997b59b0
commit b73c8668e3
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
6 changed files with 53 additions and 38 deletions

View file

@ -0,0 +1,32 @@
import { MatchableTextType } from "./matchMultipleTextTypesOnMessage";
import { AutomodContext, AutomodPluginType } from "../types";
import { messageSummary, verboseChannelMention } from "../../../utils";
import { PluginData } from "knub";
import { User } from "eris";
export function getTextMatchPartialSummary(
pluginData: PluginData<AutomodPluginType>,
type: MatchableTextType,
context: AutomodContext,
) {
if (type === "message") {
const channel = pluginData.guild.channels.get(context.message.channel_id);
const channelMention = channel ? verboseChannelMention(channel) : `\`#${context.message.channel_id}\``;
return `message in ${channelMention}:\n${messageSummary(context.message)}`;
} else if (type === "embed") {
const channel = pluginData.guild.channels.get(context.message.channel_id);
const channelMention = channel ? verboseChannelMention(channel) : `\`#${context.message.channel_id}\``;
return `message embed in ${channelMention}:\n${messageSummary(context.message)}`;
} else if (type === "username") {
return `username: ${context.user.username}`;
} else if (type === "nickname") {
return `nickname: ${context.member.nick}`;
} else if (type === "visiblename") {
const visibleName = context.member?.nick || context.user.username;
return `visible name: ${visibleName}`;
} else if (type === "customstatus") {
return `custom status: ${context.member.game.state}`;
}
}