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

463
Vistas
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 Respuestas
Responde la pregunta

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 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