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

Cchillihero2/27/2023
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
Cchillihero2/27/2023
nested arrays?
Cchillihero2/27/2023
like this?
Cchillihero2/27/2023
makes more sense like this but you get the point
Cchillihero2/27/2023
requiredUserPermissions: ['Administrator', ['ManageGuild', 'ManageRoles']],
LLioness1002/27/2023
Yes So this would be Administrator and (either manage guild or channels)
Cchillihero2/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?
LLioness1002/27/2023
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
Cchillihero2/27/2023
not the same logic?
LLioness1002/27/2023
Lemme check the source code
Solution
LLioness1002/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 }
]
]
preconditions: [
{ name: 'UserPermissions', context: { permissions: PermissionFlags.Administrator } },
[
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageGuild },
{ name: 'UserPermissions', context: { permissions: PermissionFlags.ManageChannels }
]
]
LLioness1002/27/2023
which represents this ^^^

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Getting modalSubmit error over the weekendDid discord change something???How to use windows env variables using skyra env utilitiesi am trying to use CD for hosting and i have env variables set on windows, how do i access them withPattern for fetching all registered slash commandsI have some slash commands and some with subcommands and and want to introduce a `/help` slash comminteraction.showModal not workinginteraction.showModal doesnt work, I dont know why. Code: ``` this.container.logger.debug("Start EdPrecondition with Slash CommandHow to report precondition failure w/ clash command? If I use `this.error({ message: 'error' });` iHow to use skyra env utilities with the cli generated project?I want to use env variables to store my mongo uri, but due to skyra utilities being their i cant useHow to get the current channel a slash command was used inI took a look at the following post https://discord.com/channels/737141877803057244/1061609301556346Preventing Commands in DMsHow do you prevent commands from being used in DMs? Message commands.autoModerationActionExecution EventDoes Sapphire not emit the Discord.js `autoModerationActionExecution` event? The following code doeHelp canceling a commandHere the code I have for a simple reminder command.https://pastebin.com/crRSdjEn. It works but id liHow to check if the bot has Permission X inside of the server? For example VIEW_AUDIT_LOGIn a listenerWhat parameter do I pass to the run method in my GuildCreate listener?Problem with this.container.stores.get().get();Code:InteractionCreate fileCan I easily create a listener for `interactionCreate`? I need it for some UI Abilities, and I am noHow to Create Threads?I dont get how to create threads programmatically. Please helpCommand infodoes sapphire have a built in command info funtions so we can get for example the aliases of a commaargs.pick("member")using `args.pick("member")`, is it intended to get the member even if you just provide 1 letter of twhy does this not work in sapphireindex.js ```js const { util } = require("./utils"); const { container } = require("@sapphire/framewoThis code is not running on sapphire```js const { Listener } = require("@sapphire/framework"); const { ActivityType } = require("discordBot stalls while registering commandsMy bot was working fine yesterday after noticing the new Cog section of the documentation (really co