"There are no more arguments." using args.pick('integer')

In this particular case I am trying to check if there is any argument after the command (while my method does work) I get an error saying "there are no more arguments" on value
let value = await args.pick('integer').catch((err) => console.log('Volume ::', err.message));

if (isNaN(value)) return message.channel.send(`Current volume is **${queue.volume}%**`);
if (Number(value) < 1 || Number(value) > 150) return message.reply(`Please send a valid value ranged between 1 to 150 (%).`);
let value = await args.pick('integer').catch((err) => console.log('Volume ::', err.message));

if (isNaN(value)) return message.channel.send(`Current volume is **${queue.volume}%**`);
if (Number(value) < 1 || Number(value) > 150) return message.reply(`Please send a valid value ranged between 1 to 150 (%).`);
Volume :: There are no more arguments.
Volume :: There are no more arguments.
I am not using args.finished of sapphire.js because that doesn't seem to check the numbers, only characters. Could proceed by simply catching the error and returning null but that seems unprofessional, any ideas?
2 Replies
awe
awe10mo ago
adding args.finished wont trigger the second check if people attend to put a value that's higher or lower than 1 or 150, and renders the command unusable if people attempt to change the volume of the player. tl;dr: only the args.finished check will get triggered
kyra
kyra10mo ago
Sounds like you want to use this pattern instead: https://www.sapphirejs.dev/docs/Guide/arguments/using-arguments#optional-arguments Which would result your code to be...
if (args.finished) {
return message.channel.send(`Current volume is **${queue.volume}%**`);
}

const value = await args.pick('integer', { minimum: 1, maximum: 150 });
if (args.finished) {
return message.channel.send(`Current volume is **${queue.volume}%**`);
}

const value = await args.pick('integer', { minimum: 1, maximum: 150 });
Sapphire Framework
Using arguments in your commands | Sapphire
This section is only for the message command and is not relevant for the other command types. If you are looking for how