I'm trying to work on perms for my bot.

It is getting stuck in the for loop. I have administrator perms so I should be able to run a command but it is saying I don't have perms. code:
//moderator only command (people who have these perms)
const modRoles = [Discord.PermissionsBitField.Flags.KickMembers, Discord.PermissionsBitField.Flags.ManageMembers, Discord.PermissionsBitField.Flags.BanMembers, Discord.PermissionsBitField.Flags.ManageRoles, Discord.PermissionsBitField.Flags.Administrator ];
let value = 0;
if(command.modOnly === 1) {
if (!message.author.id === ownerId) {
console.log(message.author.id);
constole.log(ownerId)
return message.reply({ content: `This is a command only moderators and guild/server owners can use. You do not have the required permissions. The roles you need are \`KICK MEMBERS, MANAGE MEMBERS, BAN MEMBERS, OR MANAGE ROLES\`. Please run \`${prefix}report\` if you are seeing this in error.` });
}
for (const ID of modRoles) {
if (!message.member.roles.cache.has(ID)) {
console.log(value)
console.log(modRoles)
value++
}
if (value == modRoles.length) {

message.react('❌');
message.reply({ content: `This is a command only moderators can use. You do not have the required permissions. The roles you need are \`KICK MEMBERS, MANAGE MEMBERS, BAN MEMBERS, OR MANAGE ROLES\`. Please run \`${prefix}report\` if you are seeing this in error.` });
return;
}
}
}
//moderator only command (people who have these perms)
const modRoles = [Discord.PermissionsBitField.Flags.KickMembers, Discord.PermissionsBitField.Flags.ManageMembers, Discord.PermissionsBitField.Flags.BanMembers, Discord.PermissionsBitField.Flags.ManageRoles, Discord.PermissionsBitField.Flags.Administrator ];
let value = 0;
if(command.modOnly === 1) {
if (!message.author.id === ownerId) {
console.log(message.author.id);
constole.log(ownerId)
return message.reply({ content: `This is a command only moderators and guild/server owners can use. You do not have the required permissions. The roles you need are \`KICK MEMBERS, MANAGE MEMBERS, BAN MEMBERS, OR MANAGE ROLES\`. Please run \`${prefix}report\` if you are seeing this in error.` });
}
for (const ID of modRoles) {
if (!message.member.roles.cache.has(ID)) {
console.log(value)
console.log(modRoles)
value++
}
if (value == modRoles.length) {

message.react('❌');
message.reply({ content: `This is a command only moderators can use. You do not have the required permissions. The roles you need are \`KICK MEMBERS, MANAGE MEMBERS, BAN MEMBERS, OR MANAGE ROLES\`. Please run \`${prefix}report\` if you are seeing this in error.` });
return;
}
}
}
I don't understand. Also, should I continue using Discord.PermissionsBitFields.Flags or are there numbers I could use instead? Cause I believe djs is moving away from hadcoding strings like this?
2 Replies
d.js docs
d.js docs2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers. Tag suggestion for @dudethatserin: Checking for things to not be equal in JavaScript:
- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other
- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other
• Comparison operators in JavaScript: learn more
Erin
Erin2y ago
I am trying to do this both ways. Regardless of the name, it should be modPerms but it still doesn’t work It doesn’t have anything to do with this either Good to know Oh fudge. I didn’t even see that Myb I thought it was just the modRoles name you were referring to That explains it lol