Skip to content

Commit

Permalink
FIXED BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmGhOsTy committed May 18, 2024
1 parent cb96d7d commit 38b2b09
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/event/messageCreate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Collection } = require("discord.js");
const { Collection, PermissionsBitField } = require("discord.js");
const StickyMessage = require('../database/schemas/stickyMessage');

module.exports = async (client, message) => {
Expand Down Expand Up @@ -71,8 +71,14 @@ module.exports = async (client, message) => {

// Permission checker
if (props.permissions) {
if (!message.member.permissions.has(props.permissions)) {
return message.reply(`You're missing permissions: ${props.permissions.map(p => `**${p}**`).join(', ')}`);

const combinedPermissions = new PermissionsBitField(props.permissions.reduce((acc, perm) => acc | perm, 0n));


if (!message.member.permissions.has(combinedPermissions)) {
const missingPermissions = combinedPermissions.toArray().filter(permission => !message.member.permissions.has(permission)).map(permission => permission);

return message.reply(`You're missing permissions: ${missingPermissions.map(p => `**${p}**`).join(', ')}`);
}
}

Expand Down

0 comments on commit 38b2b09

Please sign in to comment.