Just recently finished up codeacademy's Learn JavaScript and currently working my way through the Discord.js guide. Learning how to command handle and came across something I didn't quite understand.
const fs = require('fs');
module.exports = {
name: 'reload',
description: 'Reloads a command',
execute(message, args) {
const commandName = args[0].toLowerCase();
const command = message.client.commands.get(commandName)
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
},
};
These lines of code:
message.client.commands.get(commandName)
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
1. I am confused as to what "||" means (is it 'or', if so I do not understand this syntax)
2. I do not know where 'cmd' is coming from.
Edit: Embarrassing mistake on my part. I was just a bit confused. All cleared up thank you.