discord.js/node : filter().map() best method
Maybe this is better :

let roles = msg.mentions.roles.filter(role =&gt; (args[2] === role.toString() || args[3] === role.toString())).map(role =&gt; role.id);


And use roles.length instead of nbArgs++ :

// Get text
let txtContent = msg.content.split(/ +/g).splice(roles.length + nbArgs).join(' ');