From 2af16228921bb4815dca055ebd20176cfb07a7e4 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 10 Oct 2022 10:52:12 +0300 Subject: [PATCH] bugfixes --- src/structure/components/observers/Automoderation.js | 2 +- src/structure/components/observers/GuildLogging.js | 3 ++- src/structure/components/settings/logging/Messages.js | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 3a05eff..265b017 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -519,7 +519,7 @@ module.exports = class AutoModeration extends Observer { filterResult.filter = 'link'; if (!silent && perms?.has('SendMessages')) { - const res = await this.client.rateLimiter.limitSend(msg.channel, wrapper.format('L_FILTER_DELETE', { user: author.id }), undefined, 'linkFilter'); + const res = await this.client.rateLimiter.limitSend(channel, wrapper.format('L_FILTER_DELETE', { user: author.id }), undefined, 'linkFilter'); //const res = await msg.formattedRespond(`L_FILTER_DELETE`, { params: { user: author.id } }); //if (res) res.delete({ timeout: 10000 }); setTimeout(() => { diff --git a/src/structure/components/observers/GuildLogging.js b/src/structure/components/observers/GuildLogging.js index b59c146..a7a235c 100644 --- a/src/structure/components/observers/GuildLogging.js +++ b/src/structure/components/observers/GuildLogging.js @@ -597,7 +597,7 @@ class GuildLogger extends Observer { if (img.height && img.width) embed.image = { url: img.url }; } - await hook.send({ embeds: [embed] }).catch(this.logger.error); + await hook.send({ embeds: [embed] }).catch(this.logger.error.bind(this.logger)); } else { @@ -677,6 +677,7 @@ class GuildLogger extends Observer { await hook.send({ embeds: [embed] }).catch((err) => { this.logger.error('Error in message edit:\n' + err.stack + `\n${inspect(embed)}`); + if (err.code === 10015) wrapper.updateWebhook('messages'); }); } diff --git a/src/structure/components/settings/logging/Messages.js b/src/structure/components/settings/logging/Messages.js index 06ac517..98c3002 100644 --- a/src/structure/components/settings/logging/Messages.js +++ b/src/structure/components/settings/logging/Messages.js @@ -92,6 +92,9 @@ class MessageLog extends Setting { }; let hook = await guild.getWebhook(this.name); + // Ensure the webhook actually exists + hook = await this.client.fetchWebhook(hook.id).catch(() => null); + if (hook) await hook.edit({ channel }); else { hook = await channel.createWebhook({