Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Message#editable): update editable check in threads locked #9216

Merged
merged 5 commits into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/discord.js/src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down