mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 09:35:02 +00:00
Update backend/src/plugins/CustomEvents/actions/addRoleAction.ts
Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
parent
dabdd4cad4
commit
3e81e076b7
1 changed files with 1 additions and 2 deletions
|
@ -28,8 +28,7 @@ export async function addRoleAction(
|
||||||
if (event.trigger.type === "command" && !canActOn(pluginData, eventData.msg.member, target)) {
|
if (event.trigger.type === "command" && !canActOn(pluginData, eventData.msg.member, target)) {
|
||||||
throw new ActionError("Missing permissions");
|
throw new ActionError("Missing permissions");
|
||||||
}
|
}
|
||||||
const targetRoles = [...target.roles.cache.keys()];
|
const rolesToAdd = (Array.isArray(action.role) ? action.role : [action.role]).filter(id => !target.roles.cache.has(id));
|
||||||
const rolesToAdd = (Array.isArray(action.role) ? action.role : [action.role]).filter(id => !targetRoles.includes(id));
|
|
||||||
if (rolesToAdd.length === 0) {
|
if (rolesToAdd.length === 0) {
|
||||||
throw new ActionError("Target already has the role(s) specified");
|
throw new ActionError("Target already has the role(s) specified");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue