Anyone have any clue what I am doing wrong

// Get the mentioned member from the message
const member = message.mentions.members.first();
if (!member) return message.channel.send('You need to mention a member to mute.');

// Check if the member has the required permissions
if (member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return message.channel.send('You cannot mute an administrator.');
}
// Get the mentioned member from the message
const member = message.mentions.members.first();
if (!member) return message.channel.send('You need to mention a member to mute.');

// Check if the member has the required permissions
if (member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return message.channel.send('You cannot mute an administrator.');
}
12 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
sharma ji
sharma jiOP10mo ago
[email protected] /data/data/com.termux/files/home/Milanio └── [email protected] Node => v20.11.1 Error I am getting
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at PermissionsBitField.resolve (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:174:11)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:60:28)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
at Object.run (/data/data/com.termux/files/home/Milanio/src/commands/prefix/Moderation/mute.js:24:32)
at Object.run (/data/data/com.termux/files/home/Milanio/src/events/Guild/messageCreate.js:140:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'BitFieldInvalid'
} Promise {
<rejected> RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at PermissionsBitField.resolve (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:174:11)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:60:28)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
at Object.run (/data/data/com.termux/files/home/Milanio/src/commands/prefix/Moderation/mute.js:24:32)
at Object.run (/data/data/com.termux/files/home/Milanio/src/events/Guild/messageCreate.js:140:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'BitFieldInvalid'
}
}
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at PermissionsBitField.resolve (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:174:11)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:60:28)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
at Object.run (/data/data/com.termux/files/home/Milanio/src/commands/prefix/Moderation/mute.js:24:32)
at Object.run (/data/data/com.termux/files/home/Milanio/src/events/Guild/messageCreate.js:140:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'BitFieldInvalid'
} Promise {
<rejected> RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at PermissionsBitField.resolve (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:174:11)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/BitField.js:60:28)
at PermissionsBitField.has (/data/data/com.termux/files/home/Milanio/node_modules/discord.js/src/util/PermissionsBitField.js:92:82)
at Object.run (/data/data/com.termux/files/home/Milanio/src/commands/prefix/Moderation/mute.js:24:32)
at Object.run (/data/data/com.termux/files/home/Milanio/src/events/Guild/messageCreate.js:140:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'BitFieldInvalid'
}
}
ShompiFlen
ShompiFlen10mo ago
can you show your code how are you importing PermissionsBitField into this script?
sharma ji
sharma jiOP10mo ago
@ShompiFlen Yes Wait
const { Message, PermissionsBitField, EmbedBuilder } = require('discord.js');
const { Message, PermissionsBitField, EmbedBuilder } = require('discord.js');
Like this
ShompiFlen
ShompiFlen10mo ago
yes
sharma ji
sharma jiOP10mo ago
So What I am doing wrong
ShompiFlen
ShompiFlen10mo ago
thats what im trying to answer. can you console.log(PermissionsBitField)
sharma ji
sharma jiOP10mo ago
[class PermissionsBitField extends BitField] {
Flags: {
CreateInstantInvite: 1n,
KickMembers: 2n,
BanMembers: 4n,
Administrator: 8n,
ManageChannels: 16n,
ManageGuild: 32n,
AddReactions: 64n,
ViewAuditLog: 128n,
PrioritySpeaker: 256n,
Stream: 512n,
ViewChannel: 1024n,
SendMessages: 2048n,
SendTTSMessages: 4096n,
ManageMessages: 8192n,
EmbedLinks: 16384n,
AttachFiles: 32768n,
ReadMessageHistory: 65536n,
MentionEveryone: 131072n,
UseExternalEmojis: 262144n,
ViewGuildInsights: 524288n,
Connect: 1048576n,
Speak: 2097152n,
MuteMembers: 4194304n,
DeafenMembers: 8388608n,
MoveMembers: 16777216n,
UseVAD: 33554432n,
ChangeNickname: 67108864n,
ManageNicknames: 134217728n,
ManageRoles: 268435456n,
ManageWebhooks: 536870912n,
ManageEmojisAndStickers: 1073741824n,
ManageGuildExpressions: 1073741824n,
UseApplicationCommands: 2147483648n,
RequestToSpeak: 4294967296n,
ManageEvents: 8589934592n,
ManageThreads: 17179869184n,
CreatePublicThreads: 34359738368n,
CreatePrivateThreads: 68719476736n,
UseExternalStickers: 137438953472n,
SendMessagesInThreads: 274877906944n,
UseEmbeddedActivities: 549755813888n,
ModerateMembers: 1099511627776n,
ViewCreatorMonetizationAnalytics: 2199023255552n,
UseSoundboard: 4398046511104n,
UseExternalSounds: 35184372088832n,
SendVoiceMessages: 70368744177664n
},
All: 114349209288703n,
Default: 104324673n,
StageModerator: 20971536n,
DefaultBit: 0n
}
[class PermissionsBitField extends BitField] {
Flags: {
CreateInstantInvite: 1n,
KickMembers: 2n,
BanMembers: 4n,
Administrator: 8n,
ManageChannels: 16n,
ManageGuild: 32n,
AddReactions: 64n,
ViewAuditLog: 128n,
PrioritySpeaker: 256n,
Stream: 512n,
ViewChannel: 1024n,
SendMessages: 2048n,
SendTTSMessages: 4096n,
ManageMessages: 8192n,
EmbedLinks: 16384n,
AttachFiles: 32768n,
ReadMessageHistory: 65536n,
MentionEveryone: 131072n,
UseExternalEmojis: 262144n,
ViewGuildInsights: 524288n,
Connect: 1048576n,
Speak: 2097152n,
MuteMembers: 4194304n,
DeafenMembers: 8388608n,
MoveMembers: 16777216n,
UseVAD: 33554432n,
ChangeNickname: 67108864n,
ManageNicknames: 134217728n,
ManageRoles: 268435456n,
ManageWebhooks: 536870912n,
ManageEmojisAndStickers: 1073741824n,
ManageGuildExpressions: 1073741824n,
UseApplicationCommands: 2147483648n,
RequestToSpeak: 4294967296n,
ManageEvents: 8589934592n,
ManageThreads: 17179869184n,
CreatePublicThreads: 34359738368n,
CreatePrivateThreads: 68719476736n,
UseExternalStickers: 137438953472n,
SendMessagesInThreads: 274877906944n,
UseEmbeddedActivities: 549755813888n,
ModerateMembers: 1099511627776n,
ViewCreatorMonetizationAnalytics: 2199023255552n,
UseSoundboard: 4398046511104n,
UseExternalSounds: 35184372088832n,
SendVoiceMessages: 70368744177664n
},
All: 114349209288703n,
Default: 104324673n,
StageModerator: 20971536n,
DefaultBit: 0n
}
@ShompiFlen here you go
ShompiFlen
ShompiFlen10mo ago
hmmm okay so this file /Milanio/src/commands/prefix/Moderation/mute.js:24:32) line 24 is the same you sent at the beginning?
sharma ji
sharma jiOP10mo ago
@ShompiFlen I am really sorry for wasting your time buddy but I got the issue actually is I have 2 files mute.js and unmute.js so I was running mute here and editing unmute.js :dogeHaHa:
ShompiFlen
ShompiFlen10mo ago
np
sharma ji
sharma jiOP10mo ago
😂 I am dumb
Want results from more Discord servers?
Add your server