Estoy tratando de hacerlo cuando la ID de usuario de alguien coincida con una variable, entonces reaccionará con ⛔. Esto funciona para todos mis otros comandos, pero cada vez que lo uso para este, reacciona con él, pero luego vamos a ejecutar el comando. ¿Algunas ideas? También a veces el mensaje se envía dos veces.
client.on('message', async message => { // Check if the user who sent the message is in the list if ((message.author.id) === bannedid) { // If user is in list, then check if message matches a command if (message.content === 'hi') { await message.react('⛔'); } } else if (message.content === 'hi') { himessage(message); function himessage(message) { var messages = ['hi uwu', 'owo', 'no', 'stinky', 'amongus', 'The FitnessGram PACER Test is a multistage aerobic capacity test that progressively gets more difficult as it continues. The test is used to measure a students aerobic capacity as part of the FitnessGram assessment. Students run back and forth as many times as they can, each lap signaled by a beep sound. The test get progressively faster as it continues until the student reaches their max lap score. The PACER Test score is combined in the FitnessGram software with scores for muscular strength, endurance, flexibility and body composition to determine whether a student is in the Healthy Fitness Zone™ or the Needs Improvement Zone™.']; var cheese = Math.floor(Math.random() * messages.length) message.channel.send(messages[cheese]); } } });EDITAR:
Para responder a su problema, la razón por la que su código sigue ejecutándose es porque su if(message.content === 'hi') y else if(message.content === 'hi') devolverán true .
Para evitar eso, puede detener la ejecución del código después de reaccionar:
return message.react('⛔'); o modifique su sentencia else if :
else if((message.author.id) != bannedid && message.content === 'hi') { // your code here. }Este fue mi comentario original, donde entendí por error que su código no funcionaba, lo dejaré aquí ya que sigue siendo una forma viable de hacerlo:
Suponiendo que bannedid sea una matriz de ID, puede usar Array.prototype.some() para verificar todos los elementos de la matriz.
if(bannedid.some(element => message.author.id === element) && message.content === 'hi') { // use return here so that the code will stop executing after reacting with the emoji. return message.react('⛔'); } else { // rest of your code }