command(client, 'fight', message => { const filter = m => m.author.id === message.author.id const possibleHealth1 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] const possibleHealth2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] let j = 0 let d = 0 const author = message.author.id const member = message.mentions.users.first(); const memberName = member.username let Player1Health = 100 let Player2Health = 100 if (member === undefined) { return message.channel.send('Incorrect Syntax. Please mention a user! (!fight {user})'); // Do not proceed, there is no user. } const name = member.id; for (let i = 1; i < possibleHealth1.length; i++) { var randomIndex = Math.floor(Math.random() * (possibleHealth1.length - j)) var randomElement = possibleHealth1[randomIndex] var randomIndex2 = Math.floor(Math.random() * (possibleHealth2.length - d)) var randomElement2 = possibleHealth2[randomIndex2] const Embed = new Discord.MessageEmbed() .setTitle(`${message.author.username}'s turn!`) .setDescription('What would you like to do?\nāš”ļø Fight!\nšŸ›”ļø Protect!\nāŒ End Game') .setColor(3426654) message.channel.send(Embed).then(message => { message.react('āš”ļø') .then(() => message.react('šŸ›”ļø')) .then(() => message.react('āŒ')) const filter2 = (reaction, user) => { return ['āš”ļø', 'šŸ›”ļø', 'āŒ'].includes(reaction.emoji.name) && user.id === author; } message.awaitReactions(filter2, { max: 1, time: 30000, errors: ['time'] }).then(collected => { const reaction = collected.first(); if (reaction.emoji.name === 'āš”ļø') { Player2Health = Player2Health - randomElement2 message.channel.send(Player2Health) } else if (reaction.emoji.name === 'šŸ›”ļø') { j = 10 } else if (reaction.emoji.name === 'āŒ') { return message.channel.send('Game ended.') } }) }) const Embed2 = new Discord.MessageEmbed() .setTitle(`${memberName}'s turn!`) .setDescription('What would you like to do?\nāš”ļø Fight!\nšŸ›”ļø Protect!\nāŒ End Game') .setColor(3426654) message.channel.send(Embed2).then(async message => { message.react('āš”ļø') .then(() => message.react('šŸ›”ļø')) .then(() => message.react('āŒ')) const filter2 = (reaction, user) => { return ['āš”ļø', 'šŸ›”ļø', 'āŒ'].includes(reaction.emoji.name) && user.id === name; } message.awaitReactions(filter2, { max: 1, time: 30000, errors: ['time'] }).then(collected => { const reaction = collected.first(); if (reaction.emoji.name === 'āš”ļø') { Player2Health = Player2Health - randomElement2 message.channel.send(Player2Health) } else if (reaction.emoji.name === 'šŸ›”ļø') { j = 10 } else if (reaction.emoji.name === 'āŒ') { return message.channel.send('Game ended.') } }) }) } })