Ad

Bot List Help, How To Add New Lines And Ignore Mentions?

I'm trying to tweak a tournament bot slightly.

It has data.js that handles all the global data

exports.players = [];

and for the bot command, list.js

var users = [];
for (i = 0; i < data.players.length; i++) {
      users.push(client.users.get(data.players[i])); }
message.channel.send("`Current Participants: `" + `\n /${users}`);

How would I make the bot list each user in a new line, I've tried using \n (\n /${users}) this breaks the line after 'Current Participants:' but not after each user (e.g bot,displays,the,list,like,this).

Also, is there a way to mention each user WITHOUT pinging a notification (e.g /@Username in discord app). The bot currently adds /@ to only the first user in the list (/${users}). Thanks in advance!

Ad

Answer

You'll have to use a simple forEach and add each user seperately to a message variable.

// Dummy data. This is what the `users` looks like based on the `data` object.
var users = ['@user1', '@user2', '@user3', '@user4'];

var msg = 'Current Participants:';
users.forEach((user) => {
  msg += `\n/${user}`;
});

console.log(msg);
// message.channel.send(msg); <-- use this one in your code

Ad
source: stackoverflow.com
Ad