#Accessing SubCommand Options

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