-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requiredrole dose not work with multiple roles #197
Comments
Simple solution to get around this issue prob not perfect in any way, is to modify has-roles.js What i did is very simple, just added a part to the for loop that uses break if a role matches, and clears the table saving missing roles. if (realRole !== null && member.roles.cache.has(role)) {
missingRoles.pop();
missingRolesNames.pop();
break;
} "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const CommandErrors_1 = __importDefault(require("../enums/CommandErrors"));
module.exports = async (guild, command, instance, member, user, reply) => {
if (!guild || !member) {
return true;
}
const { error } = command;
const roles = command.getRequiredRoles(guild.id);
if (roles && roles.length) {
const missingRoles = [];
const missingRolesNames = [];
for (const role of roles) {
const realRole = await guild.roles.fetch(role);
if (realRole !== null && member.roles.cache.has(role)) {
missingRoles.pop();
missingRolesNames.pop();
break;
}
if (realRole !== null && !member.roles.cache.has(role)) {
missingRoles.push(role);
missingRolesNames.push(realRole.name);
}
}
if (missingRoles.length) {
if (error) {
error({
error: CommandErrors_1.default.MISSING_ROLES,
command,
message: null,
info: {
missingRoles,
},
});
}
else {
reply(instance.messageHandler.get(guild, 'MISSING_ROLES', {
ROLES: missingRolesNames.join(', '),
})).then((message) => {
if (!message) {
return;
}
if (instance.delErrMsgCooldown === -1 || !message.deletable) {
return;
}
setTimeout(() => {
message.delete();
}, 1000 * instance.delErrMsgCooldown);
});
}
return false;
}
}
else if (command.doesRequireRoles) {
reply(instance.messageHandler.get(guild, 'REQUIRE_ROLES', {
PREFIX: instance.getPrefix(guild),
COMMAND: command.names[0],
})).then((message) => {
if (!message) {
return;
}
if (instance.delErrMsgCooldown === -1 || !message.deletable) {
return;
}
setTimeout(() => {
message.delete();
}, 1000 * instance.delErrMsgCooldown);
});
return false;
}
return true;
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let's say I have 3 roles Admin, Mod, Temp-mod and I want all of them to use /kick
I would use /requiredrole kick ID for all 3 of them but if I was a Mod and use /kick I would get this message "You do not have the required roles to use this command! You need one of the following: Admin, Temp-mod" if I gave myself Admin and still have Mod I would get this message "You do not have the required roles to use this command! You need one of the following: Temp-mod" the command will only work if I have all 3 roles
The text was updated successfully, but these errors were encountered: