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

472
Visualizações
How can I call the options of a SubCommand using discord.js? (v13)

I've recently been working on a Discord bot using discord.js's lastest verison, v13, and slash commands. After reading through the documentation on GitHub, I was able to get a subcommand working in my bot:

enter image description here

However, when trying to get the options array from the arguments, I do not know how I can get arguments after getting the SubCommand. To my disappointment, the only function I found was .getSubcommand(), which returns a string oddly enough. I was hoping it would return on object so I can get the options array from it.

How can I get the options object that's within a subcommand? Does this even exist? How can I use the string that is returned?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

SubCommands are just subject to the slash command itself you may access the arguments of options provided within it like so:

client.on('interactionCreate', async (interaction) => {
    if (!interaction.isCommand()) return;

    if (interaction.commandName === 'settings') {
        if (interaction.options.getSubcommand() === 'moderation_logs') {
            const user = interaction.options.getChannel('logging_channel');
        }
    }
});

Treat them as normal message commands with args but better since all args correspond to the options provided even if they are different sub commands since they fall under the same interaction ( slash command ).

Slash commands are awesome 😇!

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