Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

469
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!