Skip to content

Commit ee988e3

Browse files
authored
fix(Message): update pinnable to check for migrated guilds (#11189)
* fix(Message): update `pinnable` to check for migrated guilds * refactor: requested changes * refactor: no checkAdmin and clean up the mess
1 parent 104ad75 commit ee988e3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,17 @@ class Message extends Base {
781781
*/
782782
get pinnable() {
783783
const { channel } = this;
784-
return Boolean(
785-
!this.system &&
786-
(!this.guild ||
787-
(channel?.viewable &&
788-
channel?.permissionsFor(this.client.user)?.has(PermissionFlagsBits.ManageMessages, false))),
784+
785+
if (this.system) return false;
786+
if (!this.guild) return true;
787+
if (!channel?.viewable) return false;
788+
789+
const permissions = channel?.permissionsFor(this.client.user);
790+
if (!permissions) return false;
791+
792+
return (
793+
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.PinMessages]) ||
794+
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.ManageMessages])
789795
);
790796
}
791797

0 commit comments

Comments
 (0)