Search code examples
discord.jsargs

How to check if second argument is empty in discord.js v12


My project is a reputation bot. There is a embed that displays the stars and a comment. I wanna check if the second arg(args[1]) is empty and if it is return.
Here is a hastebin with my code: https://hastebin.com/kuvufejoqa.js
I tried using if(!comment.length) return; and it didn't work. Here is what I don't want in the embed:
enter image description here


Solution

  • To check if 2nd argument is empty use

    if(!args[1]) return;
    

    args[1] is 2nd argument and if you add ! before it, it will check if it's empty