mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Migrate AutoDelete to new Plugin structure
This commit is contained in:
parent
ebcb28261b
commit
e682e9b8c5
9 changed files with 194 additions and 0 deletions
26
backend/src/plugins/AutoDelete/util/onMessageCreate.ts
Normal file
26
backend/src/plugins/AutoDelete/util/onMessageCreate.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { AutoDeletePluginType, MAX_DELAY } from "../types";
|
||||
import { PluginData } from "knub";
|
||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
||||
import { convertDelayStringToMS, resolveMember } from "src/utils";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { addMessageToDeletionQueue } from "./addMessageToDeletionQueue";
|
||||
|
||||
export async function onMessageCreate(pluginData: PluginData<AutoDeletePluginType>, msg: SavedMessage) {
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id);
|
||||
const config = pluginData.config.getMatchingConfig({ member, channelId: msg.channel_id });
|
||||
if (config.enabled) {
|
||||
let delay = convertDelayStringToMS(config.delay);
|
||||
|
||||
if (delay > MAX_DELAY) {
|
||||
delay = MAX_DELAY;
|
||||
if (!pluginData.state.maxDelayWarningSent) {
|
||||
pluginData.state.guildLogs.log(LogType.BOT_ALERT, {
|
||||
body: `Clamped auto-deletion delay in <#${msg.channel_id}> to 5 minutes`,
|
||||
});
|
||||
pluginData.state.maxDelayWarningSent = true;
|
||||
}
|
||||
}
|
||||
|
||||
addMessageToDeletionQueue(pluginData, msg, delay);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue