FerretPaws
FerretPaws

Reputation: 93

What's the best way to go about having multiple users as inputs in a command?

So, I want to create a command that uses multiple user pings as input. Here's what I have so far:

let mentionedUser = msg.mentions.users.first();

if (mentionedUser === msg.author)
 return msg.channel.send(
  `***${msg.author.username}** kisses... themselves? ~~Impressive.~~`
 );
else return msg.channel.send('Oi! You gotta actually ping a member!');

if (parameters) {
 var embed1 = new Discord.MessageEmbed()
  .setColor('#06FBFE')
  .setDescription(
   `**${msg.author.username}** kisses **${mentionedUser.username}**`
  );
 msg.channel.send(embed1);
} else return msg.channel.send('Please give me a user to kiss! :3');

How should I got about using multiple mentions without creating undefined variables?

Upvotes: 0

Views: 38

Answers (1)

Lioness100
Lioness100

Reputation: 8402

You could use Collection.map() and Array.prototype.join() to make use of multiple mentions:

.setDescription(
 `**${msg.author.username}** kisses **${message.mentions.users
  .map((user) => user.username)
  .join(', ')}**`
);

Upvotes: 1

Related Questions