[Solved] What does this if-statement exactly do?


The first if statement

if(command.name) 

checks, whether the property name of commands is empty or not.

  • If it’s empty, it will **not execute the code inside the brackets and jump straight to the else block
  • If not, it will execute the code inside the brackets

The second line

client.commands.set(command.name, command);

calls the .set() function to add a new command with these parameters to the commands collection:

  • command.name obviously the name of the command to be added
  • the command obeject itself with all properties and executable functions

solved What does this if-statement exactly do?