mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
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:
@@ -602,11 +602,17 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
get editable() {
|
get editable() {
|
||||||
const precheck = Boolean(this.author.id === this.client.user.id && (!this.guild || this.channel?.viewable));
|
const precheck = Boolean(this.author.id === this.client.user.id && (!this.guild || this.channel?.viewable));
|
||||||
|
|
||||||
// Regardless of permissions thread messages cannot be edited if
|
// 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()) {
|
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;
|
return precheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user