Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.command()
- async def numbergame(ctx,max=None):
- if not max:
- await ctx.send("Error: NumberGame: You must input a max number by doing: \"-numbergame [input max number here]\" ")
- else:
- if int(max):
- numb=random.randrange(1,int(max))
- await ctx.send("NumberGame: I'm thinking of a number between 1 and {}. Send an integer to get started.".format(max))
- await ctx.send("**NOTE:** *Sending anything which contains anything other than an integer (1 and above) will stop the game.*")
- guesses=0
- exit=False
- async def guessing(guesse, msg=None):
- msg = await bot.wait_for("message",check=lambda m: m.author.id == ctx.author.id and m.channel.id == ctx.channel.id)
- msg=msg.content
- integ=False
- try:
- int(msg)
- integ=True
- except:
- integ=False
- print("guesses: %d" % guesse)
- if integ==True:
- print("in")
- if int(msg)>numb:
- await ctx.send("NumberGame: The number is lower than %s." % msg)
- guesse+=1
- await guessing(guesse, None)
- else:
- if int(msg)<numb:
- await ctx.send("NumberGame: The number is higher than %s." % msg)
- guesse+=1
- await guessing(guesse, None)
- else:
- if int(msg)==numb:
- qck=[guesse,numb]
- await ctx.send("NumberGame: Congratulations, you guessed correctly in {} guesses. The number I was thinking of was {}.".format(guesse,numb))
- else:
- ctx.send("Error: NumberGame: This is not an integer.")
- await guessing(guesse, None)
- else:
- if msg=="exit":
- exit==False
- await ctx.send("Error: NumberGame: You fool! This is a number game, not a not number game! Enter an __*integer*__, you **fucking retard**.")
- await guessing(guesse, None)
- print(int(msg))
- print(numb)
- print(int(msg)==numb)
- await guessing(guesses, None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement