var numbers = [] for (var i = 0; i <= 36; i++) { numbers.push(i) } if (!args[0]) return message.reply("Please specify an amount!") if (args[0] != Math.floor(args[0])) return message.reply("Please use only whole numbers.") if (!args[1]) return message.reply("Please specify a color or a number! ") let cPick = ["red", "black", "green"] let colorPick = cPick[Math.floor(Math.random() * cPick.length)] let colorPickChance = cPick[Math.floor(Math.random() * cPick.length)] + Math.random() * 100 let numberPick = numbers[Math.floor(Math.random() * numbers.length)] let cs = args[1].toUpperCase() let embed = new Discord.MessageEmbed() if (args[1] === "1-12") { var ok = [] for (var i = 1; i <= 12; i++) { ok.push(i) } console.log(ok) console.log(numberPick) if (ok.includes(numberPick)) { message.reply(`you chose ${args[1]} number ${numberPick}, you win`) coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] *35) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.reply(`you chose ${args[1]} number ${numberPick}, you lose`) } } else if (args[1] === "13-24") { var ok2 = [] for (var i = 13; i <= 24; i++) { ok2.push(i) } if (ok2.includes(numberPick)) { coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] *35) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.reply(`you chose ${args[1]} number ${numberPick}, you win`) } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.reply(`you chose ${args[1]} number ${numberPick}, you lose`) } } else if (args[1] === "25-36") { var ok3 = [] for (var i = 25; i <= 36; i++) { ok3.push(i) } if (ok3.includes(numberPick)) { coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] * 35) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.reply(`you chose ${args[1]} number ${numberPick}, you win`) } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.reply(`you chose ${args[1]} number ${numberPick}, you lose`) } } else { return message.reply("Use only `1-12` `13-24` `25-36`") } if (args[1] != Math.floor(args[1]) && args[1] !== "1-12" && args[1] !== "13-24" && args[1] !== "25-36") { if (args[2] && args[2] == Math.floor(args[2])) return message.reply("You can't bet on number when you're betting on a color!") if (numberPick === 0) { colorPick = "green"; } if (cs !== "red".toUpperCase() && cs !== "black".toUpperCase() && cs !== "green".toUpperCase()) { return message.reply("The only valid colors are `red` `black` and `green`") } else { switch (args[1].toUpperCase()) { case 'red'.toUpperCase(): if (colorPick === "red") { coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] *2) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Win") .setColor(color.green) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Lost") .setColor(color.red) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } break; case 'black'.toUpperCase(): if (colorPick === "black") { coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] *2) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Win") .setColor(color.green) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Lost") .setColor(color.red) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } break; case 'green': if (colorPick === "green") { coins[message.author.id] = { coins: (coins[message.author.id].coins += args[0] * 35) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Win") .setColor(color.green) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } else { coins[message.author.id] = { coins: (coins[message.author.id].coins -= args[0]) }; fs.writeFile("./coins.json", JSON.stringify(coins), err => { if (err) console.error(err); }); message.channel.send( new Discord.MessageEmbed() .setTitle("Roulette | Lost") .setColor(color.red) .setDescription(`The ball has stopped at **${colorPick} ${numberPick}**`) ) } break; } }