#Accessing SubCommand Options

2 messages · Page 1 of 1 (latest)

light orbit
#

I am trying to get some options from a SubCommand I created, following the this guide: https://discordjs.guide/slash-commands/parsing-options.html#subcommands
However, I only get an array returned that is the size of 1, containing a 'null' value.

This is how I'm trying to get the options:

if(interaction.options.getSubcommand() === "counter")
    {
      let answersArr = [];
      console.log("Counter \n Num of Options: " + interaction.options.data.length + "\n Options:");
      for(let i = 1 /*skip null val*/; i < interaction.options.data.length; i++)
        {
          console.log(interaction.options.getString("answer" + i));
          answersArr.push(interaction.options.getString("answer" + i));
        }
    }

Any ideas?

dusky cobalt
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.