Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Chillihero
Chillihero2/27/2023
Whats the syntax to require Permission X AND Y OR Z when using requiredUserPermissions

when using requiredUserPermissions. Its an array so Im not sure
Chillihero
Chillihero2/27/2023
nested arrays?
Chillihero
Chillihero2/27/2023
like this?
Chillihero
Chillihero2/27/2023
makes more sense like this but you get the point
Chillihero
Chillihero2/27/2023
requiredUserPermissions: ['Administrator', ['ManageGuild', 'ManageRoles']],
Lioness100
Lioness1002/27/2023
Yes
Lioness100
Lioness1002/27/2023
So this would be Administrator and (either manage guild or channels)
Chillihero
Chillihero2/27/2023
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
Lioness1002/27/2023
first layer and, second or. For just or, it would be [['x', 'y']]
Lioness100
Lioness1002/27/2023
Ohhh wait wait this is required user permissions, I thought you were talking about preconditions
Lioness100
Lioness1002/27/2023
I don't know if user permissions supports that nesting, but if it does, what I said is correct
Chillihero
Chillihero2/27/2023
not the same logic?
Lioness100
Lioness1002/27/2023
Lemme check the source code

Solution Message

Lioness100
Lioness1002/27/2023
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 }
  ]
]
Lioness100
Lioness1002/27/2023
which represents this ^^^
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy