mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-24 01:55:03 +00:00
initial
This commit is contained in:
parent
6c01bb6200
commit
0f0f47a390
8 changed files with 275 additions and 1 deletions
|
@ -2,6 +2,7 @@ import { typedGuildEventListener } from "knub";
|
|||
import { RecentActionType } from "../constants";
|
||||
import { GuildSavedMessages } from "../../../data/GuildSavedMessages";
|
||||
import { runAutomod } from "../functions/runAutomod";
|
||||
import diff from "lodash.difference";
|
||||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
|
||||
export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginType>()({
|
||||
|
@ -67,3 +68,31 @@ export const RunAutomodOnThreadDelete = typedGuildEventListener<AutomodPluginTyp
|
|||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const RunAutomodOnThreadUpdate = typedGuildEventListener<AutomodPluginType>()({
|
||||
event: "threadUpdate",
|
||||
async listener({ pluginData, args: { oldThread, newThread: thread } }) {
|
||||
const user = thread.ownerId ? await pluginData.client.users.fetch(thread.ownerId).catch(() => void 0) : void 0;
|
||||
const changes: AutomodContext["threadChange"] = {};
|
||||
if (oldThread.archived !== thread.archived) {
|
||||
changes.archived = thread.archived ? thread : void 0;
|
||||
changes.unarchived = !thread.archived ? thread : void 0;
|
||||
}
|
||||
if (oldThread.locked !== thread.locked) {
|
||||
changes.locked = thread.locked ? thread : void 0;
|
||||
changes.unlocked = !thread.locked ? thread : void 0;
|
||||
}
|
||||
|
||||
if (Object.keys(changes).length === 0) return;
|
||||
|
||||
const context: AutomodContext = {
|
||||
timestamp: Date.now(),
|
||||
threadChange: changes,
|
||||
user,
|
||||
};
|
||||
|
||||
pluginData.state.queue.add(() => {
|
||||
runAutomod(pluginData, context);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue