Skip to content

Commit

Permalink
fix(Message): bulkDeletable permissions should be retrieved later f…
Browse files Browse the repository at this point in the history
…or DMs (#9146)

* fix(Message): permissions check should be done later

the getter will error if used on a message originating from a DM

* refactor: remove unessercary chaining
  • Loading branch information
NotSugden committed Feb 25, 2023
1 parent 4e0e125 commit a9495bd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/discord.js/src/structures/Message.js
Expand Up @@ -645,12 +645,11 @@ class Message extends Base {
* channel.bulkDelete(messages.filter(message => message.bulkDeletable));
*/
get bulkDeletable() {
const permissions = this.channel?.permissionsFor(this.client.user);
return (
(this.inGuild() &&
Date.now() - this.createdTimestamp < MaxBulkDeletableMessageAge &&
this.deletable &&
permissions?.has(PermissionFlagsBits.ManageMessages, false)) ??
this.channel?.permissionsFor(this.client.user).has(PermissionFlagsBits.ManageMessages, false)) ??
false
);
}
Expand Down

2 comments on commit a9495bd

@vercel
Copy link

@vercel vercel bot commented on a9495bd Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on a9495bd Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.