I'm coding a Discord bot with the javascript API, and I have an idea that I'm not sure would work, but would be a massive optimization.
Right now i'm adding a Rock Paper Scissors minigame into my bot, and I need it comparing the users guess (A sent emoji in the chat) to its own guess (A random number between 0-2 to represent the emoji of choice), and for now i have a line of if else
doing that.
e.g, instead of
if(botGuess == 0 && msg.content.includes("/*unicode fist*/"){
//tie
}
I put it in a Switch statement... kinda like this??
switch(botGuess, msg){
case botGuess = 0, msg.content.includes("/*unicode fist*/"):
//tie
break;
}
I've just been wondering for a while, is this possible, and if so am I doing it right? As of now I have alot of if else statements, and switching to an advanced switch statement like the one I thought of above would give me ease of mind.
EDIT: I've found a workaround thanks to Simperfy. I'm concatenating both variables into a string and treating them both as one variable.
e.g.
var guesses = botGuess + "|" + msg.content;
switch(guesses){
case guesses.contains("0" && "/*unicode_fist*/"):
//tie
break;
}