Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. import asyncio
  2. import random
  3. import json
  4. import time
  5. import discord
  6. from discord.ext.commands import Bot
  7.  
  8. BOT_PREFIX = "k!"
  9. TOKEN = "NjExNDQyNzU3OTkwNDgxOTIx.XVT4wQ.SE3bxqpifkDzVCTC8DoC6A1wqlc"
  10.  
  11. client = Bot(command_prefix=BOT_PREFIX)
  12. bot = Bot(command_prefix=BOT_PREFIX)
  13.  
  14. rolling = 1
  15.  
  16.  
  17. @client.event
  18. async def on_ready():
  19. print(f'We have logged in as {client.user}') # notification of login.
  20. print(discord.__version__)
  21.  
  22.  
  23. # @client.event
  24. # async def on_message(message): # event that happens per any message.
  25. # print(f"{message.channel}: {message.author}: {message.author.name}: {message.content}")
  26. # if (message.content == "k!roll")
  27.  
  28.  
  29. @client.command()
  30. async def roulette(ctx, wager: int):
  31. global rolling
  32. if rolling == 1:
  33. rolling = 0
  34. anim = 7
  35. direction = random.randint(0, 7)
  36. arrows = [
  37. ":arrow_up:",
  38. ":arrow_upper_right:",
  39. ":arrow_right:",
  40. ":arrow_lower_right:",
  41. ":arrow_down:",
  42. ":arrow_lower_left:",
  43. ":arrow_left:",
  44. ":arrow_upper_left:"
  45. ]
  46. e = discord.Embed(title="Roulette Wheel", description="Wager: " + str(wager), color=0x00AD83)
  47. e.add_field(name="----------------",
  48. value="0.5x | 3x | 0x\n1.5x |" + arrows[direction] + "| 2x\n0.3x | 2x | 0x",
  49. inline=False)
  50.  
  51. updatedembed = discord.Embed(title="Roulette Wheel", description="Wager: " + str(wager), color=0x00AD83)
  52. updatedembed.add_field(name="----------------",
  53. value="0.5x | 3x | 0x\n1.5x |" + arrows[direction] + "| 2x\n0.3x | 2x | 0x",
  54. inline=False)
  55.  
  56. msg = await ctx.send(embed=e)
  57.  
  58. while anim > 0:
  59. direction -= 1
  60. anim -= 1
  61.  
  62. updatedembed = discord.Embed(title="Roulette Wheel", description="Wager: " + str(wager), color=0x00AD83)
  63. updatedembed.add_field(name="----------------",
  64. value="0.5x | 3x | 0x\n1.5x |" + arrows[direction] + "| 2x\n0.3x | 2x | 0x",
  65. inline=False)
  66.  
  67. await msg.edit(embed=updatedembed)
  68.  
  69. if direction < 0:
  70. direction = 7
  71. if anim >= 5:
  72. await asyncio.sleep(0.5)
  73. elif anim >= 3:
  74. await asyncio.sleep(1.34)
  75. elif anim >= 0:
  76. await asyncio.sleep(2)
  77.  
  78. if anim == 0:
  79. rolling = 1
  80. if direction == 0:
  81. await ctx.send("You profited " + str(wager*3-wager) + ". Total win: " + str(wager*3))
  82. elif direction == 1 or direction == 3:
  83. await ctx.send("You lost all your bet")
  84. elif direction == 2 or direction == 4:
  85. await ctx.send("You profited " + str(wager*2-wager) + ". Total win: " + str(wager*2))
  86. elif direction == 5:
  87. await ctx.send("You lost " + str(wager-wager*0.3) + ". You only have " + str(wager*0.3) + " remaining from your bet.")
  88. elif direction == 6:
  89. await ctx.send("You profited " + str(wager*1.5-wager) + ". Total win: " + str(wager*1.5))
  90. elif direction == 7:
  91. await ctx.send("You lost " + str(wager-wager*0.5) + ". You only have " + str(wager*0.5) + " remaining from your bet.")
  92. else:
  93. await ctx.send("Rolling, please wait...")
  94.  
  95.  
  96. @client.command()
  97. async def ping(ctx):
  98. """Pings the bot"""
  99. pingtime = time.time()
  100. e = discord.Embed(title="Pinging...", colour=0xFF0000)
  101. msg = await ctx.send(embed=e)
  102. ping = time.time() - pingtime
  103. complete = "Pong, %.01f seconds" % ping
  104. em = discord.Embed(title=complete, colour=0xFF0000)
  105. await msg.edit(embed=em)
  106.  
  107.  
  108. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement