3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-19 07:20:00 +00:00
zeppelin/backend/src/plugins/Logs/events/LogsThreadModifyEvts.ts

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-07-01 02:21:16 +02:00
import { LogType } from "../../../data/LogType";
2021-07-25 14:32:08 +02:00
import { differenceToString, getScalarDifference } from "../../../utils";
import { channelToConfigAccessibleChannel } from "../../../utils/configAccessibleObjects";
2021-07-01 02:21:16 +02:00
import { logsEvt } from "../types";
export const LogsThreadCreateEvt = logsEvt({
event: "threadCreate",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.THREAD_CREATE, {
thread: channelToConfigAccessibleChannel(meta.args.thread),
2021-07-01 02:21:16 +02:00
});
},
});
export const LogsThreadDeleteEvt = logsEvt({
event: "threadDelete",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.THREAD_DELETE, {
thread: channelToConfigAccessibleChannel(meta.args.thread),
2021-07-01 02:21:16 +02:00
});
},
});
export const LogsThreadUpdateEvt = logsEvt({
event: "threadUpdate",
async listener(meta) {
const diff = getScalarDifference(meta.args.oldThread, meta.args.newThread, ["messageCount", "archiveTimestamp"]);
const differenceString = differenceToString(diff);
meta.pluginData.state.guildLogs.log(
LogType.THREAD_UPDATE,
{
oldThread: channelToConfigAccessibleChannel(meta.args.oldThread),
newThread: channelToConfigAccessibleChannel(meta.args.newThread),
differenceString,
},
meta.args.newThread.id,
);
2021-07-01 02:21:16 +02:00
},
});