fix(Message): update pinnable to use PinMessages (#11202)

* fix(Message): update `pinnable` to use `PinMessages`

* refactor: use bitwise OR

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* fix: check if in voice based channel for pinnable

* Update packages/discord.js/src/structures/Message.js

* Update packages/discord.js/src/structures/Message.js

Co-authored-by: Almeida <github@almeidx.dev>

* Update packages/discord.js/src/structures/Message.js

Co-authored-by: Almeida <github@almeidx.dev>

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
Danial Raza
2025-10-28 15:54:22 +01:00
committed by GitHub
parent 4c0d667773
commit 94a9b4d03c

View File

@@ -799,12 +799,15 @@ class Message extends Base {
*/
get pinnable() {
const { channel } = this;
return Boolean(
!this.system &&
(!this.guild ||
(channel?.viewable &&
channel?.permissionsFor(this.client.user)?.has(PermissionFlagsBits.ManageMessages, false))),
);
if (this.system) return false;
if (!this.guild) return true;
if (!channel || channel.isVoiceBased() || !channel.viewable) return false;
const permissions = channel.permissionsFor(this.client.user);
if (!permissions) return false;
return permissions.has(PermissionFlagsBits.ReadMessageHistory | PermissionFlagsBits.PinMessages);
}
/**