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
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad