3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

Custom Events fixes (#255)

This commit is contained in:
metal 2021-09-04 17:11:10 +01:00 committed by GitHub
parent 3385841702
commit f2f246ee84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -51,7 +51,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()(
} }
const values = createTypedTemplateSafeValueContainer({ const values = createTypedTemplateSafeValueContainer({
...args, ...safeArgs,
msg: messageToTemplateSafeMessage(message), msg: messageToTemplateSafeMessage(message),
}); });

View file

@ -28,9 +28,11 @@ 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 rolesToAdd = (Array.isArray(action.role) ? action.role : [action.role]).filter(
const rolesToAdd = Array.isArray(action.role) ? action.role : [action.role]; id => !target.roles.cache.has(id),
await target.edit({ );
roles: Array.from(new Set([...target.roles.cache.values(), ...rolesToAdd])) as Snowflake[], if (rolesToAdd.length === 0) {
}); throw new ActionError("Target already has the role(s) specified");
}
await target.roles.add(rolesToAdd);
} }