3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

Add logging for threads and stages

This commit is contained in:
Dark 2021-07-01 02:21:16 +02:00
parent bb9b8cfe06
commit 144c9c43e0
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
5 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,46 @@
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars } from "../../../utils";
import { logsEvt } from "../types";
export const LogsStageInstanceCreateEvt = logsEvt({
event: "stageInstanceCreate",
async listener(meta) {
const stageChannel =
meta.args.stageInstance.channel ??
(await meta.pluginData.guild.channels.fetch(meta.args.stageInstance.channelID));
meta.pluginData.state.guildLogs.log(LogType.STAGE_INSTANCE_CREATE, {
stageInstance: stripObjectToScalars(meta.args.stageInstance),
stageChannel: stripObjectToScalars(stageChannel),
});
},
});
export const LogsStageInstanceDeleteEvt = logsEvt({
event: "stageInstanceDelete",
async listener(meta) {
const stageChannel =
meta.args.stageInstance.channel ??
(await meta.pluginData.guild.channels.fetch(meta.args.stageInstance.channelID));
meta.pluginData.state.guildLogs.log(LogType.STAGE_INSTANCE_DELETE, {
stageInstance: stripObjectToScalars(meta.args.stageInstance),
stageChannel: stripObjectToScalars(stageChannel),
});
},
});
export const LogsStageInstanceUpdateEvt = logsEvt({
event: "stageInstanceUpdate",
async listener(meta) {
const stageChannel =
meta.args.newStageInstance.channel ??
(await meta.pluginData.guild.channels.fetch(meta.args.newStageInstance.channelID));
meta.pluginData.state.guildLogs.log(LogType.STAGE_INSTANCE_UPDATE, {
oldStageInstance: stripObjectToScalars(meta.args.oldStageInstance),
newStageInstance: stripObjectToScalars(meta.args.newStageInstance),
stageChannel: stripObjectToScalars(stageChannel),
});
},
});

View file

@ -0,0 +1,34 @@
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars } from "../../../utils";
import { logsEvt } from "../types";
export const LogsThreadCreateEvt = logsEvt({
event: "threadCreate",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.THREAD_CREATE, {
thread: stripObjectToScalars(meta.args.thread),
});
},
});
export const LogsThreadDeleteEvt = logsEvt({
event: "threadDelete",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.THREAD_DELETE, {
thread: stripObjectToScalars(meta.args.thread),
});
},
});
export const LogsThreadUpdateEvt = logsEvt({
event: "threadUpdate",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.THREAD_UPDATE, {
oldThread: stripObjectToScalars(meta.args.oldThread),
newThread: stripObjectToScalars(meta.args.newThread),
});
},
});