Whats the syntax to require Permission X AND Y OR Z when using requiredUserPermissions

when using requiredUserPermissions. Its an array so Im not sure
Solution:
No, required user permissions does not allow nested arrays and "and/or" logic. I recommend you just implement it in the run function. Or, use the precondition directly: ```ts preconditions: [ { name: 'UserPermissions', context: { permissions: PermissionFlags.Administrator } },...
Jump to solution
11 Replies
chillihero
chillihero16mo ago
nested arrays?
chillihero
chillihero16mo ago
like this?
chillihero
chillihero16mo ago
makes more sense like this but you get the point
chillihero
chillihero16mo ago
requiredUserPermissions: ['Administrator', ['ManageGuild', 'ManageRoles']],
Lioness100
Lioness10016mo ago
Yes So this would be Administrator and (either manage guild or channels)
chillihero
chillihero16mo ago
what would either x y or z be? just the normal brackets? or is the 1. layer and and the second one is or?
Lioness100
Lioness10016mo ago
first layer and, second or. For just or, it would be [['x', 'y']] Ohhh wait wait this is required user permissions, I thought you were talking about preconditions I don't know if user permissions supports that nesting, but if it does, what I said is correct
chillihero
chillihero16mo ago
not the same logic?
Lioness100
Lioness10016mo ago
Lemme check the source code
Solution
Lioness100
Lioness10016mo ago
No, required user permissions does not allow nested arrays and "and/or" logic. I recommend you just implement it in the run function. Or, use the precondition directly:
preconditions: [
{ name: 'UserPermissions', context: { permissions: PermissionFlags.Administrator } },
[
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageGuild },
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageChannels }
]
]
preconditions: [
{ name: 'UserPermissions', context: { permissions: PermissionFlags.Administrator } },
[
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageGuild },
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageChannels }
]
]
Lioness100
Lioness10016mo ago
which represents this ^^^