From 22e880aaa0d8c644fc8d16a524d17f4f53a056f6 Mon Sep 17 00:00:00 2001 From: Erwan Date: Wed, 22 Mar 2023 22:38:32 +0100 Subject: [PATCH] fix(Message#editable): update editable check in threads locked (#9216) * fix(Message#editable): update editable check in threads locked * fix(Message#editable): add check in archived threads * fix: check manage threads permission only if thread is locked * fix: adding a full stop at the end of a sentence Co-authored-by: Jaworek --------- Co-authored-by: Jaworek Co-authored-by: Vlad Frangu --- packages/discord.js/src/structures/Message.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index 407ede4f3..f3f13a6fd 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -602,11 +602,17 @@ class Message extends Base { */ get editable() { const precheck = Boolean(this.author.id === this.client.user.id && (!this.guild || this.channel?.viewable)); + // Regardless of permissions thread messages cannot be edited if - // the thread is locked. + // the thread is archived or the thread is locked and the bot does not have permission to manage threads. if (this.channel?.isThread()) { - return precheck && !this.channel.locked; + if (this.channel.archived) return false; + if (this.channel.locked) { + const permissions = this.permissionsFor(this.client.user); + if (!permissions?.has(PermissionFlagsBits.ManageThreads, true)) return false; + } } + return precheck; }