0

I am createing discord bot, that will do a coinflip, but i got some logical operator errors that i cant figure out whats wrong. I want that bot will respond on command if its not full command and between some strings it doesnt work. Here is whats wrong - If I type !coinflip blue - it works, the bot respond me to "choose currency" BUT IF I TYPE !coinflip red - then bot still thinks that theres nothing after !coinflip and it will say "choose a side". Please help.

if (args[0] !== ('blue'||'red')) {
    message.reply('If you do not know how to create coinflip type **!help**');
    message.reply('Choose a side [blue, red]. [Example: !coinflip **blue**].');

  } else if (args[0] === ( 'blue' || 'red' )) {
        if (args[1] !== 'ref' || args[1] !== 'key') {
          message.reply('*If you do not know how to create coinflip type **!help***');
          message.reply('Choose a currency [ref, key]. [Example: !coinflip blue **key**].');
    } else if (args[1] === 'ref' || args[1] === 'key') {etc...}
EnelGy
  • 25
  • 1
  • 7

2 Answers2

0

Rewrite this:

if (args[0] !== ('blue'||'red')) {

As any of the following:

if (args[0] !== 'blue' && args[0] !== 'red') {
if (!['blue', 'red'].includes(args[0])) {
if (!/blue|red/.test(args[0])) {

This last option resembles your current attempt most closely.

GirkovArpa
  • 4,427
  • 4
  • 14
  • 43
0
if (args[0] !== ('blue'||'red')) {

Needs to be

if ((args[0] !== 'blue') && (args[0] !== 'red')) {

'blue'||'red' will just be 'blue', which isn't what you want, assuming you want to compare args[0] to 'blue' and 'red'

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80