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 <jaworekwiadomosci@gmail.com>

---------

Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
Erwan
2023-03-22 22:38:32 +01:00
committed by GitHub
parent e9a8eb323f
commit 22e880aaa0

View File

@@ -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;
}