I'm doing a command to my discord bot, which sends back a response depending on the users response to the command. I have a while loop, where I go through all possible answers and if none of them are true, then go to else statement. However, every time the loop runs, it returns the answer depending by the first statement (if answer is high) and doesn't actually seem to care about the other elif statements. Does this have something to do with the message.content parts, since they don't seem to work at all? Here's the loop:
EDIT: added the whole event
@commands.Cog.listener()
async def on_message(self, message):
if '.highlow' in message.content:
randomnumber = random.randint(0,100)
hintnumber = random.randint(0,100)
channel = message.channel
await channel.send('Satunnainen luku on valittu väliltä ``0-100``.\n'
f'Vihjeesi on ``{hintnumber}``.\n'
'Vastaa kirjoittamalla ``high``, ``low`` tai ``vihje``.')
def check(message):
return message.content == 'high' or 'low' or 'vihje' and message.channel == channel
msg = await self.client.wait_for('message', check=check)
while True:
if message.author != self.client.user:
if 'high' in message.content:
if randomnumber > hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten voitit pelin!'.format(msg))
break
elif randomnumber < hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten hävisit pelin!'.format(msg))
break
elif 'low' in message.content:
if randomnumber < hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten voitit pelin!'.format(msg))
break
elif randomnumber > hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten hävisit pelin!'.format(msg))
break
elif 'vihje' in message.content:
if randomnumber == hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten voitit pelin!'.format(msg))
break
elif randomnumber != hintnumber:
await channel.send(f'Satunnainen luku oli ``{randomnumber}``, joten hävisit pelin!'.format(msg))
break
else:
await channel.send('Tuo ei ole oikea vaihtoehto!')
break
The command is in a cog.