Im trying to make a discord bot guessing game (using python) but it keeps failing. I have looked at many similar posts and haven't found anything that helps.
@bot.command(name='play')
async def play(ctx):
number = random.randint(1,100)
await ctx.send('I have a number in mind between 1 and 100, guess')
for i in range(0,5):
guess = await client.wait_for('message') **(see below the code)
if guess.content == number:
await ctx.send('You got it!')
elif guess.content < number:
await ctx.send('Higher!')
elif guess.content > number:
await ctx.send('Lower!')
else:
await ctx.send("You lost, type $play to play again.")
** normaly it would say: , check=check, but that doesnt seem to work, it says, check not defined or something like that
the code seems to get stuck at either: for i in range(0,5):, or: guess = await client.wait_for('message')
could someone help?, or post a guessing game that works + explanation?
check=checkassumes that you have definedcheckbefore. You can check if the message comes from the author for example. - Dominik