automod: create archives for matched spam
This commit is contained in:
parent
b73c8668e3
commit
63b77d1aaf
1 changed files with 13 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { RecentActionType } from "../constants";
|
import { RecentActionType } from "../constants";
|
||||||
import { automodTrigger } from "../helpers";
|
import { automodTrigger } from "../helpers";
|
||||||
import { getBaseUrl } from "../../../pluginUtils";
|
import { getBaseUrl } from "../../../pluginUtils";
|
||||||
import { convertDelayStringToMS, tDelayString, tNullable } from "../../../utils";
|
import { convertDelayStringToMS, sorter, tDelayString, tNullable } from "../../../utils";
|
||||||
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
||||||
import { findRecentSpam } from "./findRecentSpam";
|
import { findRecentSpam } from "./findRecentSpam";
|
||||||
import { getMatchingMessageRecentActions } from "./getMatchingMessageRecentActions";
|
import { getMatchingMessageRecentActions } from "./getMatchingMessageRecentActions";
|
||||||
|
@ -30,7 +30,12 @@ export function createMessageSpamTrigger(spamType: RecentActionType, prettyName:
|
||||||
|
|
||||||
const recentSpam = findRecentSpam(pluginData, spamType, context.message.user_id);
|
const recentSpam = findRecentSpam(pluginData, spamType, context.message.user_id);
|
||||||
if (recentSpam) {
|
if (recentSpam) {
|
||||||
// TODO: Combine with old archive
|
await pluginData.state.archives.addSavedMessagesToArchive(
|
||||||
|
recentSpam.archiveId,
|
||||||
|
[context.message],
|
||||||
|
pluginData.guild,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
silentClean: true,
|
silentClean: true,
|
||||||
};
|
};
|
||||||
|
@ -47,8 +52,12 @@ export function createMessageSpamTrigger(spamType: RecentActionType, prettyName:
|
||||||
);
|
);
|
||||||
|
|
||||||
if (matchedSpam) {
|
if (matchedSpam) {
|
||||||
// TODO: Generate archive link
|
const messages = matchedSpam.recentActions
|
||||||
const archiveId = "TODO";
|
.map(action => action.context.message)
|
||||||
|
.filter(Boolean)
|
||||||
|
.sort(sorter("posted_at"));
|
||||||
|
|
||||||
|
const archiveId = await pluginData.state.archives.createFromSavedMessages(messages, pluginData.guild);
|
||||||
|
|
||||||
pluginData.state.recentSpam.push({
|
pluginData.state.recentSpam.push({
|
||||||
type: spamType,
|
type: spamType,
|
||||||
|
|
Loading…
Add table
Reference in a new issue