From 5870b687124ccf91409cb02541b905b8b71ade88 Mon Sep 17 00:00:00 2001 From: Navy Date: Tue, 15 Jun 2021 23:46:50 +0300 Subject: [PATCH] regex tweak + promise catching --- structure/client/components/observers/Automoderation.js | 8 +++++--- structure/client/components/observers/GuildLogging.js | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/structure/client/components/observers/Automoderation.js b/structure/client/components/observers/Automoderation.js index 78d7e5d..2048cf2 100644 --- a/structure/client/components/observers/Automoderation.js +++ b/structure/client/components/observers/Automoderation.js @@ -321,7 +321,7 @@ module.exports = class AutoModeration extends Observer { for (const reg of words) { - match = content.match(new RegExp(`(?:^|\\s)${reg}`, 'iu')); + match = content.match(new RegExp(`(?:^|\\s)(${reg})`, 'iu')); if (match) break; @@ -337,7 +337,7 @@ module.exports = class AutoModeration extends Observer { `, // ** User:** <@${ author.id }> color: 15120384, fields: context.reverse().reduce((acc, val) => { - const text = val.content.length ? Util.escapeMarkdown(val.content).replace(match, '**__$&__**') : '**NO CONTENT**'; + const text = val.content.length ? Util.escapeMarkdown(val.content).replace(match[1], '**__$&__**') : '**NO CONTENT**'; acc.push({ name: `${val.author.tag} (${val.author.id}) - ${val.id}`, value: text.length < 1024 ? text : text.substring(0, 1013) + '...' @@ -350,7 +350,9 @@ module.exports = class AutoModeration extends Observer { }, []) }; - const sent = await logChannel.send({ embed }); + const sent = await logChannel.send({ embed }).catch((err) => { + this.client.logger.error('Error in message flag:\n' + err.stack); + }); } diff --git a/structure/client/components/observers/GuildLogging.js b/structure/client/components/observers/GuildLogging.js index 8397ab6..59c258e 100644 --- a/structure/client/components/observers/GuildLogging.js +++ b/structure/client/components/observers/GuildLogging.js @@ -219,7 +219,9 @@ class GuildLogger extends Observer { } - hook.send({ embeds: [embed], files: uploadedFiles }); + await hook.send({ embeds: [embed], files: uploadedFiles }).catch((err) => { + this.client.logger.error('Error in message delete:\n' + err.stack); + }); /* if(message.attachments.size > 0) {