mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
feat: use InternalPoster for Automod alerts
This commit is contained in:
parent
fe63ec9d77
commit
8ac117a6f3
2 changed files with 13 additions and 6 deletions
|
@ -36,6 +36,7 @@ import { pluginInfo } from "./info";
|
|||
import { availableTriggers } from "./triggers/availableTriggers";
|
||||
import { AutomodPluginType, ConfigSchema } from "./types";
|
||||
import { PhishermanPlugin } from "../Phisherman/PhishermanPlugin";
|
||||
import { InternalPosterPlugin } from "../InternalPoster/InternalPosterPlugin";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -193,6 +194,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
MutesPlugin,
|
||||
CountersPlugin,
|
||||
PhishermanPlugin,
|
||||
InternalPosterPlugin,
|
||||
],
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
|
|
|
@ -17,11 +17,13 @@ import {
|
|||
isTruthy,
|
||||
verboseChannelMention,
|
||||
validateAndParseMessageContent,
|
||||
chunkMessageLines,
|
||||
} from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { automodAction } from "../helpers";
|
||||
import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { messageIsEmpty } from "../../../utils/messageIsEmpty";
|
||||
import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin";
|
||||
|
||||
export const AlertAction = automodAction({
|
||||
configType: t.type({
|
||||
|
@ -36,7 +38,7 @@ export const AlertAction = automodAction({
|
|||
const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake);
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
|
||||
if (channel && (channel instanceof TextChannel || channel instanceof ThreadChannel)) {
|
||||
if (channel && channel instanceof TextChannel) {
|
||||
const text = actionConfig.text;
|
||||
const theMessageLink =
|
||||
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 {
|
||||
await createChunkedMessage(
|
||||
channel,
|
||||
rendered,
|
||||
erisAllowedMentionsToDjsMentionOptions(actionConfig.allowed_mentions),
|
||||
);
|
||||
const poster = pluginData.getPlugin(InternalPosterPlugin);
|
||||
const chunks = chunkMessageLines(rendered);
|
||||
for (const chunk of chunks) {
|
||||
await poster.sendMessage(channel, {
|
||||
content: rendered,
|
||||
allowedMentions: erisAllowedMentionsToDjsMentionOptions(actionConfig.allowed_mentions),
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.code === 50001) {
|
||||
logs.logBotAlert({
|
||||
|
|
Loading…
Add table
Reference in a new issue