• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Numbergame

a guest Sep 16th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. @bot.command()
2. async def numbergame(ctx,max=None):
3.     if not max:
4.         await ctx.send("Error: NumberGame: You must input a max number by doing: \"-numbergame [input max number here]\" ")
5.     else:
6.         if int(max):
7.             numb=random.randrange(1,int(max))
8.             await ctx.send("NumberGame: I'm thinking of a number between 1 and {}. Send an integer to get started.".format(max))
9.             await ctx.send("**NOTE:** *Sending anything which contains anything other than an integer (1 and above) will stop the game.*")
10.             guesses=0
11.             exit=False
12.             async def guessing(guesse, msg=None):
13.                 msg = await bot.wait_for("message",check=lambda m: m.author.id == ctx.author.id and m.channel.id == ctx.channel.id)
14.                 msg=msg.content
15.
16.                 integ=False
17.
18.                 try:
19.                     int(msg)
20.                     integ=True
21.                 except:
22.                     integ=False
23.
24.                 print("guesses: %d" % guesse)
25.                 if integ==True:
26.                     print("in")
27.                     if int(msg)>numb:
28.                         await ctx.send("NumberGame: The number is lower than %s." % msg)
29.                         guesse+=1
30.                         await guessing(guesse, None)
31.                     else:
32.                         if int(msg)<numb:
33.                             await ctx.send("NumberGame: The number is higher than %s." % msg)
34.                             guesse+=1
35.                             await guessing(guesse, None)
36.                         else:
37.                             if int(msg)==numb:
38.                                 qck=[guesse,numb]
39.                                 await ctx.send("NumberGame: Congratulations, you guessed correctly in {} guesses. The number I was thinking of was {}.".format(guesse,numb))
40.                             else:
41.                                 ctx.send("Error: NumberGame: This is not an integer.")
42.                                 await guessing(guesse, None)
43.                 else:
44.                     if msg=="exit":
45.                         exit==False
46.
47.                     await ctx.send("Error: NumberGame: You fool! This is a number game, not a not number game! Enter an __*integer*__, you **fucking retard**.")
48.                     await guessing(guesse, None)
49.                     print(int(msg))
50.                     print(numb)
51.                     print(int(msg)==numb)
52.             await guessing(guesses, None)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top