mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
higher limit & add chunk clean code
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
801cd2630b
commit
2ad03267a5
1 changed files with 11 additions and 5 deletions
|
@ -6,12 +6,12 @@ import { LogType } from "../../../data/LogType";
|
||||||
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin";
|
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin";
|
||||||
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { allowTimeout } from "../../../RegExpRunner";
|
import { allowTimeout } from "../../../RegExpRunner";
|
||||||
import { DAYS, getInviteCodesInString, noop, SECONDS } from "../../../utils";
|
import { chunkArray, DAYS, getInviteCodesInString, noop, SECONDS } from "../../../utils";
|
||||||
import { utilityCmd, UtilityPluginType } from "../types";
|
import { utilityCmd, UtilityPluginType } from "../types";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
||||||
|
|
||||||
const MAX_CLEAN_COUNT = 150;
|
const MAX_CLEAN_COUNT = 300;
|
||||||
const MAX_CLEAN_TIME = 1 * DAYS;
|
const MAX_CLEAN_TIME = 1 * DAYS;
|
||||||
const MAX_CLEAN_API_REQUESTS = 20;
|
const MAX_CLEAN_API_REQUESTS = 20;
|
||||||
const CLEAN_COMMAND_DELETE_DELAY = 10 * SECONDS;
|
const CLEAN_COMMAND_DELETE_DELAY = 10 * SECONDS;
|
||||||
|
@ -33,9 +33,15 @@ export async function cleanMessages(
|
||||||
idsToDelete.forEach((id) => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
|
idsToDelete.forEach((id) => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
|
||||||
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE_BULK, idsToDelete[0]);
|
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE_BULK, idsToDelete[0]);
|
||||||
|
|
||||||
// Actually delete the messages
|
// Actually delete the messages (in chunks of 100)
|
||||||
channel.bulkDelete(idsToDelete);
|
|
||||||
await pluginData.state.savedMessages.markBulkAsDeleted(idsToDelete);
|
const chunks = chunkArray(idsToDelete, 100);
|
||||||
|
await Promise.all(
|
||||||
|
chunks.map(async (chunk) => {
|
||||||
|
await channel.bulkDelete(chunk);
|
||||||
|
await pluginData.state.savedMessages.markBulkAsDeleted(chunk);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
// Create an archive
|
// Create an archive
|
||||||
const archiveId = await pluginData.state.archives.createFromSavedMessages(savedMessages, pluginData.guild);
|
const archiveId = await pluginData.state.archives.createFromSavedMessages(savedMessages, pluginData.guild);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue