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

@ -26,6 +26,10 @@
"CHANNEL_DELETE": "🗑 Channel {channelMention(channel)} was deleted",
"CHANNEL_EDIT": "✏ Channel {channelMention(channel)} was edited",
"THREAD_CREATE": "🖊 Thread {channelMention(thread)} was created in channel <#{thread.parentID}>",
"THREAD_DELETE": "🗑 Thread {channelMention(thread)} was deleted/archived from channel <#{thread.parentID}>",
"THREAD_UPDATE": "✏ Thread {channelMention(newThread)} was edited. Previous name: `{oldThread.name}`",
"ROLE_CREATE": "🖊 Role **{role.name}** (`{role.id}`) was created",
"ROLE_DELETE": "🖊 Role **{role.name}** (`{role.id}`) was deleted",
"ROLE_EDIT": "🖊 Role **{role.name}** (`{role.id}`) was edited",
@ -42,6 +46,10 @@
"VOICE_CHANNEL_FORCE_MOVE": "\uD83C\uDF99 ✍ {userMention(member)} was moved from **{oldChannel.name}** to **{newChannel.name}** by {userMention(mod)}",
"VOICE_CHANNEL_FORCE_DISCONNECT": "\uD83C\uDF99 🚫 {userMention(member)} was forcefully disconnected from **{oldChannel.name}** by {userMention(mod)}",
"STAGE_INSTANCE_CREATE": "📣 Stage Instance `{stageInstance.topic}` was created in Stage Channel <#{stageChannel.id}>",
"STAGE_INSTANCE_DELETE": "📣 Stage Instance `{stageInstance.topic}` was deleted in Stage Channel <#{stageChannel.id}>",
"STAGE_INSTANCE_UPDATE": "📣 Stage Instance `{newStageInstance.topic}` was edited in Stage Channel <#{stageChannel.id}>. Previous topic: `{oldStageInstance.topic}`",
"COMMAND": "🤖 {userMention(member)} used command in {channelMention(channel)}:\n`{command}`",
"MESSAGE_SPAM_DETECTED": "🛑 {userMention(member)} spam detected in {channelMention(channel)}: {description} (more than {limit} in {interval}s)\n{archiveUrl}",

View file

@ -19,6 +19,10 @@ export enum LogType {
CHANNEL_CREATE,
CHANNEL_DELETE,
THREAD_CREATE,
THREAD_DELETE,
THREAD_UPDATE,
ROLE_CREATE,
ROLE_DELETE,
@ -31,6 +35,10 @@ export enum LogType {
VOICE_CHANNEL_LEAVE,
VOICE_CHANNEL_MOVE,
STAGE_INSTANCE_CREATE,
STAGE_INSTANCE_DELETE,
STAGE_INSTANCE_UPDATE,
COMMAND,
MESSAGE_SPAM_DETECTED,

View file

@ -15,6 +15,12 @@ import { LogsChannelCreateEvt, LogsChannelDeleteEvt } from "./events/LogsChannel
import { LogsGuildMemberAddEvt } from "./events/LogsGuildMemberAddEvt";
import { LogsGuildMemberRemoveEvt } from "./events/LogsGuildMemberRemoveEvt";
import { LogsRoleCreateEvt, LogsRoleDeleteEvt } from "./events/LogsRoleModifyEvts";
import {
LogsStageInstanceCreateEvt,
LogsStageInstanceDeleteEvt,
LogsStageInstanceUpdateEvt,
} from "./events/LogsStageInstanceModifyEvts";
import { LogsThreadCreateEvt, LogsThreadDeleteEvt, LogsThreadUpdateEvt } from "./events/LogsThreadModifyEvts";
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts";
import { LogsVoiceStateUpdateEvt } from "./events/LogsVoiceChannelEvts";
import { ConfigSchema, FORMAT_NO_TIMESTAMP, LogsPluginType } from "./types";
@ -67,6 +73,12 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
LogsRoleCreateEvt,
LogsRoleDeleteEvt,
LogsVoiceStateUpdateEvt,
LogsStageInstanceCreateEvt,
LogsStageInstanceDeleteEvt,
LogsStageInstanceUpdateEvt,
LogsThreadCreateEvt,
LogsThreadDeleteEvt,
LogsThreadUpdateEvt,
],
public: {

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),
});
},
});