3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

feat: use InternalPoster for Automod alerts

This commit is contained in:
Dragory 2021-11-02 22:12:57 +02:00
parent fe63ec9d77
commit 8ac117a6f3
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 13 additions and 6 deletions

View file

@ -36,6 +36,7 @@ import { pluginInfo } from "./info";
import { availableTriggers } from "./triggers/availableTriggers"; import { availableTriggers } from "./triggers/availableTriggers";
import { AutomodPluginType, ConfigSchema } from "./types"; import { AutomodPluginType, ConfigSchema } from "./types";
import { PhishermanPlugin } from "../Phisherman/PhishermanPlugin"; import { PhishermanPlugin } from "../Phisherman/PhishermanPlugin";
import { InternalPosterPlugin } from "../InternalPoster/InternalPosterPlugin";
const defaultOptions = { const defaultOptions = {
config: { config: {
@ -193,6 +194,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
MutesPlugin, MutesPlugin,
CountersPlugin, CountersPlugin,
PhishermanPlugin, PhishermanPlugin,
InternalPosterPlugin,
], ],
configSchema: ConfigSchema, configSchema: ConfigSchema,

View file

@ -17,11 +17,13 @@ import {
isTruthy, isTruthy,
verboseChannelMention, verboseChannelMention,
validateAndParseMessageContent, validateAndParseMessageContent,
chunkMessageLines,
} from "../../../utils"; } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { automodAction } from "../helpers"; import { automodAction } from "../helpers";
import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { messageIsEmpty } from "../../../utils/messageIsEmpty"; import { messageIsEmpty } from "../../../utils/messageIsEmpty";
import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin";
export const AlertAction = automodAction({ export const AlertAction = automodAction({
configType: t.type({ configType: t.type({
@ -36,7 +38,7 @@ export const AlertAction = automodAction({
const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake); const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake);
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
if (channel && (channel instanceof TextChannel || channel instanceof ThreadChannel)) { if (channel && channel instanceof TextChannel) {
const text = actionConfig.text; const text = actionConfig.text;
const theMessageLink = const theMessageLink =
contexts[0].message && messageLink(pluginData.guild.id, contexts[0].message.channel_id, contexts[0].message.id); contexts[0].message && messageLink(pluginData.guild.id, contexts[0].message.channel_id, contexts[0].message.id);
@ -90,11 +92,14 @@ export const AlertAction = automodAction({
} }
try { try {
await createChunkedMessage( const poster = pluginData.getPlugin(InternalPosterPlugin);
channel, const chunks = chunkMessageLines(rendered);
rendered, for (const chunk of chunks) {
erisAllowedMentionsToDjsMentionOptions(actionConfig.allowed_mentions), await poster.sendMessage(channel, {
); content: rendered,
allowedMentions: erisAllowedMentionsToDjsMentionOptions(actionConfig.allowed_mentions),
});
}
} catch (err) { } catch (err) {
if (err.code === 50001) { if (err.code === 50001) {
logs.logBotAlert({ logs.logBotAlert({