TaraHarkon
DIAdiscord.js - Imagine an app
•Created by TaraHarkon on 3/9/2024 in #djs-questions
getInteger not working for one option but is working for another?
Basically, I have a dice roller bot and in a new command I'm working on, I can get one of my integers options but not the other. It fails with a
TypeError: Cannot read properties of undefined (reading 'getInteger')
Here is the code:
data: new SlashCommandBuilder() .setName('multiroll') .setDescription('Test command') .addIntegerOption(option => option.setName('times-to-roll') .setDescription('The number of times you would like the die rolled') .setRequired(true)) .addStringOption(option => option.setName('type-of-dice') .setDescription('The die roll to make') .setRequired(true)) .addIntegerOption(option => option.setName('mod') .setDescription('The modifier for the roll') .setRequired(false)), async execute(interaction) { const mult = interaction.options.getInteger('times-to-roll'); const string = interaction.options.getString('type-of-dice').toLowerCase(); const modifier = interaction.option.getInteger('mod', false) ?? 0; const rolls = [];
10 replies