Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
slash command discord permission

I want to have a slash command that only admin can use but I can't find the option for this purpose

const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');

const commands = [
    
    new SlashCommandBuilder().setName('setting').setDescription('Replies with the setting!').setDefaultPermission(false)
    
    .addSubcommand(subcommand => subcommand.setName('log').setDescription('Select a user')
        .addChannelOption(option => option.setName('log-channel').setDescription('Select a channel'))
        .addStringOption(option => option.setName('delete-log').setDescription('Delete log channel'))), 
]
   .map(command => command.toJSON());

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

This is my slash command when I'am using this code the command is locked so this is good for when the user is not an admin enter image description here

But I want the command to be unlucked when the user as the permission admin like so

enter image description here

So I was wondering if I could set the permission for the command like this

const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');

const commands = [
    
    new SlashCommandBuilder().setName('setting').setDescription('Replies with the setting!').setDefaultPermission(false).setPermission('ADMINISTRATOR')
    
    .addSubcommand(subcommand => subcommand.setName('log').setDescription('Select a user')
        .addChannelOption(option => option.setName('log-channel').setDescription('Select a channel'))
        .addStringOption(option => option.setName('delete-log').setDescription('Delete log channel'))), 
]
   .map(command => command.toJSON());

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

From the documentation,

const permissions = [
  {
      id: '464464090157416448',
      type: 'ROLE',
      permission: false,
  },
];

await command.permissions.add({ permissions });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda