mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +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_channels: t.array(t.string),
|
||||||
excluded_categories: t.array(t.string),
|
excluded_categories: t.array(t.string),
|
||||||
exclude_bots: t.boolean,
|
exclude_bots: t.boolean,
|
||||||
|
excluded_roles: t.array(t.string),
|
||||||
format: tNullable(tLogFormats),
|
format: tNullable(tLogFormats),
|
||||||
timestamp_format: t.string,
|
timestamp_format: t.string,
|
||||||
include_embed_timestamp: t.boolean,
|
include_embed_timestamp: t.boolean,
|
||||||
|
|
|
@ -2,11 +2,16 @@ import { GuildPluginData } from "knub";
|
||||||
import { LogsPluginType, TLogChannelMap } from "../types";
|
import { LogsPluginType, TLogChannelMap } from "../types";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
import { createChunkedMessage, noop } from "../../../utils";
|
import { createChunkedMessage, get, noop } from "../../../utils";
|
||||||
import { getLogMessage } from "./getLogMessage";
|
import { getLogMessage } from "./getLogMessage";
|
||||||
import { allowTimeout } from "../../../RegExpRunner";
|
import { allowTimeout } from "../../../RegExpRunner";
|
||||||
|
|
||||||
const excludedUserProps = ["user", "member", "mod"];
|
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) {
|
export async function log(pluginData: GuildPluginData<LogsPluginType>, type: LogType, data: any) {
|
||||||
const logChannels: TLogChannelMap = pluginData.config.get().channels;
|
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 this entry is from an excluded channel, skip it
|
||||||
if (opts.excluded_channels) {
|
if (opts.excluded_channels) {
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Add table
Reference in a new issue