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
chilliheroOP2y ago
nested arrays?
chillihero
chilliheroOP2y ago
like this?
chillihero
chilliheroOP2y ago
makes more sense like this but you get the point
chillihero
chilliheroOP2y ago
requiredUserPermissions: ['Administrator', ['ManageGuild', 'ManageRoles']],
Lioness100
Lioness1002y ago
Yes So this would be Administrator and (either manage guild or channels)
chillihero
chilliheroOP2y 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
Lioness1002y 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
chilliheroOP2y ago
not the same logic?
Lioness100
Lioness1002y ago
Lemme check the source code
Solution
Lioness100
Lioness1002y 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
Lioness1002y ago
which represents this ^^^
Want results from more Discord servers?
Add your server