Estoy buscando una manera de tener un comando que dé diferentes respuestas dependiendo de si ha etiquetado a alguien junto con el comando.
Esto es lo que tengo hasta ahora:
module.exports = { name: 'attack', description: "uses attack embed", execute(message, args, Discord) { var newEmbed = new Discord.MessageEmbed() .setColor('#A5775C') .setDescription(message.author.username + ' *attacked* '+ message.mentions.members.first().username); var newEmbed1 = new Discord.MessageEmbed() .setColor('#A5775C') .setDescription(message.author.username + ' *attacked the enemy!*'); if (message.mentions.members.first()) { message.channel.send({embeds: [newEmbed]}); }else{ message.channel.send({embeds: [newEmbed1]}); } } }Cuando pruebo este formato, el comando en el que haces ping a alguien funciona, pero cuando no haces ping a alguien, no pasa nada.
Gracias por la ayuda.
Pruebe este código, requiere menos código y buscará un objetivo.
let target if (message.mentions.members.first() === undefined) { target = 'the enemy.' } else { target = message.mentions.members.first().username } const newEmbed = new Discord.MessageEmbed() .setColor('#A5775C') .setDescription(`${message.author} attacked ${target}`) message.channel.send({ embeds: [newEmbed] })