Slash per-subcommand permissions
Currently there is no way to set permissions for specific slash subcommands. They can only be set for the command as a whole using .setDefaultMemberPermissions() or passing a sole object. I have a large bot for which I decided recode all legacy commands into slash commands. I ran into this problem that I have commands with some subcommands that can be ran by everyone, and some subcommands that can only be ran by administrators or require some other permission. When I started with slash commands I first thought I would be able to set required permissions for each subcommand, but that is apparently not the case. I know that I can make my own handler to handle subcommand permissions, but the thing is, when a user doesnt have required permissions for a slash command, it is hidden from the user when he types /. And thats what I want to achieve for subcommands. I want a user to see only subcommands that he has access to, other subcommands should be hidden from them.
I got an idea of making all commands without subcommands to bypass this. But obviously that is not how it should be and makes subcommands useless.
So to sum it up, I am wondering if assigning required permissions for individual slash subcommands will be possible. Are you planning to add that feature or will you consider it if you havent thought about it yet?
-
Would like to see that feature as well!
1 -
Would love to see this as well - ran into the same problem just now!
1 -
I would love to see this as well.. I wanted a delete and report subcommand added to a command, but now I have to do some sketchy stuff bypassing this, by requiring the server admins to add a role that is required to use the delete command.
0 -
until they roll out a feature, you can use something like this though:
const { PermissionFlagsBits } = require("discord.js"); async execute(interaction) { if (!interaction.member.permissions.has(PermissionFlagsBits.ManageMessages)) { await interaction.reply("Insufficient permissions!"); return; } };This will quickly return “Insufficient permissions!” as a reply to the user sending the slash command. This will still show the command to said user, but as long as they do not have the set permissions (in this case to Manage Messages) they will not be able to execute the command
Hope this helped!
0 -
Sage- that works as a hard coded implementation, but I think the point of this suggestion is for server owners to be able to customise these permissions for each subcommand through the UI.
1 -
Paul- of course! It would be great to see a proper implementation, I only suggested this as an option in the meantime, as this allows some limitation. Additionally, you could set up a choice based command, that can edit hard-coded permissions for different subcommands, though on the backend you would have to save these choices in a separate database. All kind of wonky, but this may be good to implement for the time being, as Discord has not changed this yet sadly
0
Iniciar sesión para dejar un comentario.
Comentarios
6 comentarios