mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
Add excluded_roles to logs
This commit is contained in:
parent
eed4fd586b
commit
6038996f10
2 changed files with 22 additions and 1 deletions
|
@ -21,6 +21,7 @@ const LogChannel = t.partial({
|
|||
excluded_channels: t.array(t.string),
|
||||
excluded_categories: t.array(t.string),
|
||||
exclude_bots: t.boolean,
|
||||
excluded_roles: t.array(t.string),
|
||||
format: tNullable(tLogFormats),
|
||||
timestamp_format: t.string,
|
||||
include_embed_timestamp: t.boolean,
|
||||
|
|
|
@ -2,11 +2,16 @@ import { GuildPluginData } from "knub";
|
|||
import { LogsPluginType, TLogChannelMap } from "../types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { TextChannel } from "eris";
|
||||
import { createChunkedMessage, noop } from "../../../utils";
|
||||
import { createChunkedMessage, get, noop } from "../../../utils";
|
||||
import { getLogMessage } from "./getLogMessage";
|
||||
import { allowTimeout } from "../../../RegExpRunner";
|
||||
|
||||
const excludedUserProps = ["user", "member", "mod"];
|
||||
const excludedRoleProps = ["message.member.roles", "member.roles"];
|
||||
|
||||
function isRoleArray(value: any): value is string[] {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
||||
export async function log(pluginData: GuildPluginData<LogsPluginType>, type: LogType, data: any) {
|
||||
const logChannels: TLogChannelMap = pluginData.config.get().channels;
|
||||
|
@ -36,6 +41,21 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
|
|||
}
|
||||
}
|
||||
|
||||
if (opts.excluded_roles) {
|
||||
for (const prop of excludedRoleProps) {
|
||||
const roles = get(data, prop);
|
||||
if (!isRoleArray(roles)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const role of roles) {
|
||||
if (opts.excluded_roles.includes(role)) {
|
||||
continue logChannelLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this entry is from an excluded channel, skip it
|
||||
if (opts.excluded_channels) {
|
||||
if (
|
||||
|
|
Loading…
Add table
Reference in a new issue