Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @commands.command(aliases=["payday"])
- async def daily(self, ctx):
- connection = await aiomysql.connect(user=config.db.user,
- password=config.db.password,
- host=config.db.host,
- port=config.db.port,
- db=config.db.database)
- user = ctx.message.author
- if await self.usercheck("economy", user.id) is False:
- await ctx.send("You don't have a bank account 😦, use `register` to make one.")
- return
- else:
- async with connection.cursor() as cur:
- await cur.execute(f"SELECT payday FROM economy WHERE userid = {user.id}")
- getdb = await cur.fetchone()
- timenow = datetime.datetime.utcfromtimestamp(time.time()).strftime("%d")
- timecheck = datetime.datetime.utcfromtimestamp(int(getdb[0])).strftime("%d")
- if timecheck == timenow:
- tomorrow = datetime.datetime.replace(datetime.datetime.now() + datetime.timedelta(days=1),
- hour=0, minute=0, second=0)
- delta = tomorrow - datetime.datetime.now()
- timeleft = time.strftime("%H", time.gmtime(delta.seconds))
- await ctx.send(f"Wait another {timeleft} hours before using daily again...")
- return
- async with connection.cursor() as cur:
- await cur.execute(f"SELECT balance FROM economy WHERE userid = {user.id}")
- eco = await cur.fetchone()
- eco = int(eco[0])
- # Voters X3 Payday #############################
- url = "https://discordbots.org/api/bots/310039170792030211/votes"
- async with aiohttp.ClientSession(headers={"Authorization": config.dbots.key}) as cs:
- async with cs.get(url) as r:
- res = await r.json()
- for x in res:
- if str(x['id']) == str(ctx.message.author.id):
- async with connection.cursor() as cur:
- await cur.execute(f"UPDATE economy SET balance = {eco + 7500} WHERE userid = {user.id}")
- await connection.commit()
- await cur.execute(f"UPDATE economy SET payday = {int(time.time())} WHERE userid = {user.id}")
- await connection.commit()
- embed = discord.Embed(color=0xDEADBF,
- title="Daily Credits",
- description="Recieved 2500 + 5000 Daily credits - Voter Bonus!")
- await ctx.send(embed=embed)
- break
- #################################################
- else:
- async with connection.cursor() as cur:
- await cur.execute(f"UPDATE economy SET balance = {eco + 2500} WHERE userid = {user.id}")
- await connection.commit()
- await cur.execute(f"UPDATE economy SET payday = {int(time.time())} WHERE userid = {user.id}")
- await connection.commit()
- embed = discord.Embed(color=0xDEADBF,
- title="Daily Credits",
- description="Recieved 2500 Daily credits!")
- embed.set_footer(text="Pssst voting will give you 3 times the daily bonus OwO, vote with .vote")
- await ctx.send("Received 2500 credits!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement