I am having issues with a timer command in discord.js. I'd like to check if the user inputted a valid time as an argument:
case 'timer':
let time = args[1];
if(!time) {
return message.reply("<:what:784258557067526174> Please specify a time!");
}
message.reply(`Timer started for ${ms(ms(time))}`)
setTimeout(function(){
message.reply('your timer has ended')
}, ms(time));
break;
The way the code is supposed to work is seen in the first example in the image. If the user type the command with a valid time, the bot starts a timer and responds with "Timer started for %time%".
But I want it to respond with a certain message if an invalid input is entered, as seen in the second example in the image:
Read more here: https://stackoverflow.com/questions/65710548/problems-with-number-inputs-on-discord-js
Content Attribution
This content was originally published by Guacamole15 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.