3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

fix(logs): use log type strings for include/exclude

This commit is contained in:
Dragory 2018-07-31 20:23:33 +03:00
parent 0d6bd097c8
commit d3dbb9f479

View file

@ -10,8 +10,8 @@ import isEqual from "lodash.isequal";
import diff from "lodash.difference"; import diff from "lodash.difference";
interface ILogChannel { interface ILogChannel {
include?: LogType[]; include?: string[];
exclude?: LogType[]; exclude?: string[];
} }
interface ILogChannelMap { interface ILogChannelMap {
@ -53,13 +53,15 @@ export class LogsPlugin extends Plugin {
async log(type, data) { async log(type, data) {
const logChannels: ILogChannelMap = this.configValue("channels"); const logChannels: ILogChannelMap = this.configValue("channels");
const typeStr = LogType[type];
for (const [channelId, opts] of Object.entries(logChannels)) { for (const [channelId, opts] of Object.entries(logChannels)) {
const channel = this.guild.channels.get(channelId); const channel = this.guild.channels.get(channelId);
if (!channel || !(channel instanceof TextChannel)) continue; if (!channel || !(channel instanceof TextChannel)) continue;
if ( if (
(opts.include && opts.include.includes(type)) || (opts.include && opts.include.includes(typeStr)) ||
(opts.exclude && !opts.exclude.includes(type)) (opts.exclude && !opts.exclude.includes(typeStr))
) { ) {
const message = this.getLogMessage(type, data); const message = this.getLogMessage(type, data);
if (message) await channel.createMessage(message); if (message) await channel.createMessage(message);