Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1.  
  2.  
  3.  
  4. class DoubleOrNothing(BaseCog):
  5. """Doubles your money or destroys it!"""
  6. def __init__(self):
  7. self.last_work = {}
  8.  
  9. @commands.group(autohelp=True)
  10. async def doubleorno(self, ctx: commands.Context):
  11. """Double or Nothing"""
  12. pass
  13.  
  14.  
  15. @doubleorno.command()
  16. async def bet(self, ctx: commands.Context, bet: int):
  17. """random number
  18. If you get 3 or below, all money lost
  19. If you get 4 or above, your money is doubled.
  20. """
  21. if bet < 200:
  22. return await ctx.send("You need to bet at least 200 credits.")
  23. else:
  24. await bank.withdraw_credits(ctx.author, bet)
  25. await ctx.send(str(bet) + " credits have been withdrawn out of your account")
  26.  
  27. dice = random.randint(1, 6)
  28. if dice <=3:
  29. await ctx.send("Bad luck! You have lost " + str(bet) + " credits.")
  30. elif dice >= 4:
  31. await ctx.send("WOOHOO! YOU JUST DOUBLED YOUR BET!")
  32. wonmoney = bet + bet
  33. await bank.deposit_credits(ctx.author, wonmoney)
  34. await ctx.send(str(wonmoney) + " credits have been deposited. Happy spending!")
  35.  
  36. await ctx.send("Note: When the fun stops, stop!")
  37.  
  38. @commands.group(autohelp=True)
  39. async def job(self, ctx: commands.Context):
  40. """Core command; job. Get a job!"""
  41. pass
  42.  
  43. @job.command()
  44. async def work(self, ctx: commands.Context):
  45. """Sub command of job. Start working at your job!"""
  46. jobpay = random.randint(1, 100)
  47. await ctx.send("You just worked at your job and earned " + str(jobpay) +" credits!")
  48. await bank.deposit_credits(ctx.author, jobpay)
  49. if ctx.message.author.id in self.last_work and time.time() - self.last_work[ctx.message.author.id] < X:
  50. await ctx.send("You must wait before running the command again")
  51. return
  52. self.last_work[ctx.message.author.id] = time.time()
  53.  
  54.  
  55.  
  56.  
  57. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement