mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-18 07:35:02 +00:00
chore: move saved message clean-up loop with other global loops
This commit is contained in:
parent
394573318d
commit
72d5d9d17a
3 changed files with 17 additions and 15 deletions
|
@ -2,26 +2,11 @@ import { GuildChannel, Message } from "discord.js";
|
|||
import moment from "moment-timezone";
|
||||
import { getRepository, Repository } from "typeorm";
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
||||
import { isAPI } from "../globals";
|
||||
import { QueuedEventEmitter } from "../QueuedEventEmitter";
|
||||
import { MINUTES, SECONDS } from "../utils";
|
||||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { cleanupMessages } from "./cleanup/messages";
|
||||
import { ISavedMessageData, SavedMessage } from "./entities/SavedMessage";
|
||||
import { buildEntity } from "./buildEntity";
|
||||
|
||||
if (!isAPI()) {
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupMessages();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
// Start first cleanup 30 seconds after startup
|
||||
setTimeout(cleanup, 30 * SECONDS);
|
||||
}
|
||||
|
||||
export class GuildSavedMessages extends BaseGuildRepository {
|
||||
private messages: Repository<SavedMessage>;
|
||||
protected toBePermanent: Set<string>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue