javascript - Two problems with one block of code (Random is the same and ifs are not doing anything when condition is met) -
contains bit of discord.js code, it's explained
what i'm trying make when user uses specific command, starts random variable, used add random enemy. when use command though, gives me same number (which used 4, after changing code little bit, 1), , doesn't number supposed (the if statement not start)
my code think having problem:
var e = math.floor(math.random() * 3) + 1; if(e = 1){ userdata.skeletons + 1; } else if(e = 2){ userdata.skeletons + 1; } else if (e = 3){ userdata.minotaurs + 1; } else if(e = 4){ userdata.skeletons + 1; } console.log(e)
the complete code:
if (message.content.startswith(prefix + "search")) { //if message //user sends equal prefix (bp!) plus word search, runs //below code if(userdata.stamina >= 3){ userdata.stamina - 3 var e = math.floor(math.random() * 3) + 1; if(e = 1){ userdata.skeletons + 1; } else if(e = 2){ userdata.skeletons + 1; } else if (e = 3){ userdata.minotaurs + 1; } else if(e = 4){ userdata.skeletons + 1; } console.log(e) message.reply('to see if ya found anything, use bp!enemies') //replies user used command above message } else{ //this else if not have enough stamina message.reply('you require @ least 3 stamina this!') console.log(`${message.author.id} require @ least 3 stamina this!`) } }
i've created comments need bit more understanding of code , discord.js code.
i've checked userdata variables (variables unique each user), , they're right. i've looked through other questions, didn't had solution thank taking time read this.
Comments
Post a Comment