diff --git a/src/localization/en_gb/observers/en_gb_errorLog.lang b/src/localization/en_gb/observers/en_gb_errorLog.lang index 9a24c6f..04a0386 100644 --- a/src/localization/en_gb/observers/en_gb_errorLog.lang +++ b/src/localization/en_gb/observers/en_gb_errorLog.lang @@ -39,6 +39,9 @@ The channel in which the message was no longer exists. [WORDWATCHER_MISSING_MEMBER] Missing target member for action **{actionType}**. +[LINKFILTER_WARN_TITLE] +{emoji_warning} __**Linkfilter Warning**__ + [LINKFILTER_WARN] Failed to validate domain `{domain}`. If this is a valid domain, add it to the greylist to ensure it is filtered. \ No newline at end of file diff --git a/src/structure/components/observers/ErrorLog.js b/src/structure/components/observers/ErrorLog.js index 2e20e9b..a5587a7 100644 --- a/src/structure/components/observers/ErrorLog.js +++ b/src/structure/components/observers/ErrorLog.js @@ -18,7 +18,8 @@ class ErrorLog extends Observer { ['automodError', this.automod.bind(this)], ['wordWatcherError', this.wordWatcher.bind(this)], ['logError', this.logError.bind(this)], - ['utilityError', this.utilityError.bind(this)] + ['utilityError', this.utilityError.bind(this)], + ['linkFilterWarn', this.linkFilterWarn.bind(this)] ]; } @@ -48,13 +49,13 @@ class ErrorLog extends Observer { async automod({ fatal, reason, infraction }) { const { guild, target, type } = infraction; - const settings = await guild.settings(); - const { errors } = settings; - const { channel: _channel, types } = errors; - if (!_channel) return; + // const settings = await guild.settings(); + // const { errors } = settings; + // const { channel: _channel, types } = errors; + // if (!_channel) return; - const channel = await guild.resolveChannel(_channel); - if (!channel) return; + // const channel = await guild.resolveChannel(_channel); + // if (!channel) return; const str = `${guild.format('AUTOMOD_ERROR', { channel: infraction.channel.id, @@ -63,45 +64,57 @@ class ErrorLog extends Observer { infractionReason: infraction.reason, reason: guild.format(`${reason}_AUTOMOD`) })}`; + const embed = { + description: str, + color: COLOURS[fatal ? 'fatal' : 'warning'] + }; - this.client.rateLimiter.limitSend(channel, { - embeds: [{ - description: str, - color: COLOURS[fatal ? 'fatal' : 'warning'] - }] - }, null, 'automodError'); + // this.client.rateLimiter.limitSend(channel, { + // embeds: [{ + // description: str, + // color: COLOURS[fatal ? 'fatal' : 'warning'] + // }] + // }, null, 'automodError'); + + this.post(guild, embed, 'automodError'); } async wordWatcher({ message, guild, warning }) { - const settings = await guild.settings(); - const { errors } = settings; - const { channel: _channel, types } = errors; - if (!_channel) return; + // const settings = await guild.settings(); + // const { errors } = settings; + // const { channel: _channel, types } = errors; + // if (!_channel) return; - const channel = await guild.resolveChannel(_channel); - if (!channel) return; + // const channel = await guild.resolveChannel(_channel); + // if (!channel) return; const str = `${guild.format(`WORDWATCHER_${warning ? 'WARN' : 'ERROR'}`)}\n${message}`; + const embed = { + description: str, + color: COLOURS[warning ? 'warning' : 'fatal'] + }; - this.client.rateLimiter.limitSend(channel, { - embeds: [{ - description: str, - color: COLOURS[warning ? 'warning' : 'fatal'] - }] - }, null, 'wordWatcherError'); + // this.client.rateLimiter.limitSend(channel, { + // embeds: [{ + // description: str, + // color: COLOURS[warning ? 'warning' : 'fatal'] + // }] + // }, null, 'wordWatcherError'); + + this.post(guild, embed, 'wordWatcherError'); } async utilityError({ guild, utility, reason, params }) { - const settings = await guild.settings(); - const { errors } = settings; - const { channel: _channel, types } = errors; - if (!_channel) return; + // const settings = await guild.settings(); + // const { errors } = settings; + // const { channel: _channel, types } = errors; + // if (!_channel) return; - const channel = await guild.resolveChannel(_channel); - if (!channel) return; + // const channel = await guild.resolveChannel(_channel); + // if (!channel) return; const embed = { description: guild.format(`UTILITY_ERROR`, { @@ -111,7 +124,27 @@ class ErrorLog extends Observer { color: COLOURS.warning }; - this.client.rateLimiter.limitSend(channel, { embeds: [embed] }, null, 'utilityError'); + // this.client.rateLimiter.limitSend(channel, { embeds: [embed] }, null, 'utilityError'); + this.post(guild, embed, 'utilityError'); + } + + linkFilterWarn({ guild, message }) { + const embed = { + description: `${guild.format('LINKFILTER_WARN_TITLE')}\n\n${message}`, + color: COLOURS.warning + }; + this.post(guild, embed, 'linkFilterWarn'); + } + + async post(guild, embed, type) { + const settings = await guild.settings(); + const { errors } = settings; + const { channel: _channel, types } = errors; + if (!_channel) return; + + const channel = await guild.resolveChannel(_channel); + if (!channel) return; + this.client.rateLimiter.limitSend(channel, { embeds: [embed] }, null, type); } }