Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. import discord
  2. import random
  3. import asyncio
  4. import sys, traceback
  5. from discord import opus
  6. import time
  7. from discord.ext import commands
  8. from pymongo import MongoClient
  9. import pymongo
  10. import random
  11. import datetime
  12. import datetime
  13. from datetime import datetime
  14. from datetime import datetime, timedelta
  15. from datetime import date
  16.  
  17. url = "url"
  18. cooldown = [50]
  19.  
  20. def year(method=datetime):
  21. now = method.now()
  22. return (now.strftime("%Y"))
  23.  
  24. def hora(method=datetime):
  25. now = method.now()
  26. return (now.strftime("%H:%M"))
  27.  
  28. class rpg(commands.Cog):
  29. def __init__(self, client):
  30. self.client = client
  31.  
  32. @commands.command()
  33. async def registrar(self, ctx):
  34. try:
  35. mongo = MongoClient(url)
  36. luiz13 = mongo["luiz13"]
  37. rpg = luiz13['rpg']
  38. rpg = luiz13.rpg.find_one({"_id":str(ctx.author.id)})
  39. if rpg is None:
  40. usuario = {"_id":str(ctx.author.id),"usuario":str(ctx.author.name), "coins":100}
  41. luiz13.rpg.insert_one(usuario).inserted_id
  42. await ctx.send(f"Olá {ctx.author.mention} você foi registrado com sucesso!!!")
  43. except:
  44. await ctx.send(f"Olá {ctx.author.mention},Você Já está registrado.")
  45.  
  46. @commands.command()
  47. async def saldo(self, ctx):
  48. try:
  49. mongo = MongoClient(url)
  50. luiz13 = mongo["luiz13"]
  51. rpg = luiz13['luiz13']
  52. rpg = luiz13.rpg.find_one({"_id":str(ctx.author.id)})
  53. if rpg is None:
  54. await ctx.send(f"Olá {ctx.author.mention},Você não está registrado Digite l!registrar para se registrar.")
  55. else:
  56. moedas = rpg["coins"]
  57. arma = rpg["ak47"]
  58. xp = rpg["xp"]
  59. car = rpg["Carro"]
  60. embedrpg = discord.Embed(title=f'Seu Saldo {ctx.author.mention} ',color=0x83f68a)
  61. embedrpg.add_field(name='Suas Moedas:',value=moedas,inline=False)
  62. await ctx.send(embed=embedrpg)
  63.  
  64. @commands.command()
  65. async def job(self, ctx):
  66. if ctx.author.id in cooldown:
  67. await ctx.send(f"Olá {ctx.author.mention},Você Precisa Aguardar 30 minutos para voltar a utilizar esse comando.")
  68. return
  69. try:
  70. mongo = MongoClient(url)
  71. mordomodiscordpython = mongo["luiz13"]
  72. rpg = luiz13['rpg']
  73. rpg = luiz13.rpg.find_one({"_id":str(ctx.author.id)})
  74. if rpg is None:
  75. await ctx.send(f"Olá {ctx.author.mention},Você não está registrado Digite l!registrar para se registrar.")
  76. else:
  77. coins = random.randint(0,300)
  78. moedas = int(rpg["coins"])+int(coins)
  79. luiz13.rpg.update_one({"_id":str(ctx.author.id)},{"$set":{"coins":int(moedas)}})
  80. await ctx.send(f"Olá {ctx.author.mention},Você Ganhou{coins} Moedas Agora.")
  81. cooldown.append(ctx.author.id)
  82. await asyncio.sleep(1800)
  83. cooldown.remove(ctx.author.id)
  84.  
  85. def setup(client):
  86. client.add_cog(rpg(client))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement