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, {
|
2021-07-06 05:23:47 +02:00
|
|
|
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, {
|
2021-07-06 05:23:47 +02:00
|
|
|
thread: channelToConfigAccessibleChannel(meta.args.thread),
|
2021-07-01 02:21:16 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const LogsThreadUpdateEvt = logsEvt({
|
|
|
|
event: "threadUpdate",
|
|
|
|
|
|
|
|
async listener(meta) {
|
2021-07-01 04:40:39 +02:00
|
|
|
const diff = getScalarDifference(meta.args.oldThread, meta.args.newThread, ["messageCount", "archiveTimestamp"]);
|
|
|
|
const differenceString = differenceToString(diff);
|
|
|
|
|
2021-07-06 05:23:47 +02:00
|
|
|
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
|
|
|
},
|
|
|
|
});
|