I wanted to program a discord bot as can be easily recognized by the title.
My problem is that I get an error when I enter, for example .args-info "fnfjsn", the bot no longer works. I have already looked for a solution on the internet and unfortunately found nothing, but now I've ended up here
I am happy about any help and thank you in advance for your help
const args = msg.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (command === 'args-info') {
if (!args.length) {
return msg.channel.send(`You didn't provide any arguments, ${msg.author}!`);
}
msg.channel.send(`Command name: ${command}\nArguments: ${args}`);
MojangAPI.nameToUuid(`${args}`, function (err, res) {
if (err) {
console.log(err);
} else {
console.log(res[0].name + "? No, they're " + res[0].id + ' to me.');
}
});
}
The error:
} else if(res[0].*name* != null) {
TypeError: Cannot read property '*name*' of undefined