Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
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 Respostas
Responde à pergunta

0

From the documentation,

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

await command.permissions.add({ permissions });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda