Custom Events fixes (#255)
This commit is contained in:
parent
3385841702
commit
f2f246ee84
2 changed files with 8 additions and 6 deletions
|
@ -51,7 +51,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()(
|
|||
}
|
||||
|
||||
const values = createTypedTemplateSafeValueContainer({
|
||||
...args,
|
||||
...safeArgs,
|
||||
msg: messageToTemplateSafeMessage(message),
|
||||
});
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ export async function addRoleAction(
|
|||
if (event.trigger.type === "command" && !canActOn(pluginData, eventData.msg.member, target)) {
|
||||
throw new ActionError("Missing permissions");
|
||||
}
|
||||
|
||||
const rolesToAdd = Array.isArray(action.role) ? action.role : [action.role];
|
||||
await target.edit({
|
||||
roles: Array.from(new Set([...target.roles.cache.values(), ...rolesToAdd])) as Snowflake[],
|
||||
});
|
||||
const rolesToAdd = (Array.isArray(action.role) ? action.role : [action.role]).filter(
|
||||
id => !target.roles.cache.has(id),
|
||||
);
|
||||
if (rolesToAdd.length === 0) {
|
||||
throw new ActionError("Target already has the role(s) specified");
|
||||
}
|
||||
await target.roles.add(rolesToAdd);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue