title: Parse Arguments from Discord interactions
body: <p>I am currently coding a discord bot and wanted to play around with the new interaction feature (aka slash-commands).</p>
  <p>I managed to get a &quot;/test&quot; Interaction working, and the bot receives the command and executes my code for it (following discord.js manual). Now I know from <code>interaction.commandName</code> what name for example the command has (in this case &quot;test&quot;), but I don’t seem to be able to get the arguments that are passed in.</p>
  <p>Following is my &quot;test.js&quot;, which is for the &quot;/test&quot; command:</p>
  <pre class="lang-js prettyprint-override"><code>const { SlashCommandBuilder } = require('@discordjs/builders');
  
  module.exports = {
      data: new SlashCommandBuilder()
          .setName('test')
          .setDescription('Test with arguments!')
      .addStringOption(option =&gt;
        option.setName(&quot;device&quot;)
          .setDescription(&quot;Some argument&quot;)
          .setRequired(true)
          .addChoice(&quot;Arg A&quot;, &quot;A&quot;)
          .addChoice(&quot;Arg B&quot;, &quot;B&quot;)
      ),
      async execute(interaction, log) {
          // log is a function to log to a file...
          // Ignore it, since it is not *currently* in use.
   
          return interaction.reply(&quot;You selected the argument ????&quot;)
      
          // Delete message after 5 seconds
          .then(setTimeout(() =&gt; interaction.deleteReply(), 5000));
      },
  };
  </code></pre>
  <p>The command itself gets called by a function that is also from the documentation of discord.js:</p>
  <pre class="lang-js prettyprint-override"><code>client.on('interactionCreate', async(interaction) =&gt; {
    if (!interaction.isCommand()) return;
  
      const command = client.commands.get(interaction.commandName);
  
      if (!command) return;
  
      try {
          await command.execute(interaction, log);
      } catch (error) {
          console.error(error);
          await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
      }
  });
  </code></pre>
  <p>I looked through the documentation and searched quite a bit online, but I don’t seem to find anything.
  If anyone could help me that would be great.</p>