Skip to content

Commit

Permalink
random stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Mar 7, 2024
1 parent b911afa commit 709a87c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
16 changes: 9 additions & 7 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ async def add_user(user: voltage.User, isbot:bool=False): # long ass fucking fun
"wallet": 0,
"bank": 0,
"total": 0,
"daily": time.time(),
"monthly": time.time(),
"data": {
"inventory": {
"Bank Loan": 1
Expand Down Expand Up @@ -127,7 +129,8 @@ async def add_user(user: voltage.User, isbot:bool=False): # long ass fucking fun
"beta": False,
"familyfriendly": False,
"isBot": isbot,
"banned": False
"banned": False,
"afk": {}
}
})
return "Added"
Expand Down Expand Up @@ -892,16 +895,16 @@ async def withdraw(ctx, amount):
@eco.command(name="monthly", description="Claim your monthly reward! (50,000 - 150,000 coins!)")
async def monthly(ctx):
if (await userdb.find_one({"userid": ctx.author.id})):
print((await userdb.find_one({"userid": ctx.author.id}))["economy"]["monthly"], time.time())
if time.time() < (await userdb.find_one({"userid": ctx.author.id}))["economy"]["monthly"]:
elapsed_time = int(time.time() - (await userdb.find_one({"userid": ctx.author.id}))['economy']['monthly'])
elapsed_time = int((await userdb.find_one({"userid": ctx.author.id}))['economy']['monthly'] - time.time())
days, remainder = divmod(elapsed_time, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
description = f"{str(days)+'d ' if days > 0 else ''}{str(hours) + 'h ' if hours > 0 else ''}{str(minutes) + 'm ' if minutes > 0 else ''}{seconds}s"
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"Please wait {description} before claiming your monthly reward!",
description=f"Please wait `{str(days)+'d ' if days > 0 else ''}{str(hours) + 'h ' if hours > 0 else ''}{str(minutes) + 'm ' if minutes > 0 else ''}{str(seconds) + 's' if seconds > 0 else ''}` before claiming your monthly reward!",
color="#dc3545"
)
return await ctx.reply(embed=embed)
Expand Down Expand Up @@ -931,15 +934,14 @@ async def monthly(ctx):
async def daily(ctx):
if (await userdb.find_one({"userid": ctx.author.id})):
if time.time() < (await userdb.find_one({"userid": ctx.author.id}))["economy"]["daily"]:
elapsed_time = int(time.time() - (await userdb.find_one({"userid": ctx.author.id}))['economy']['daily'])
elapsed_time = int((await userdb.find_one({"userid": ctx.author.id}))['economy']['daily'] - time.time())
days, remainder = divmod(elapsed_time, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
description = f"{str(days)+'d ' if days > 0 else ''}{str(hours) + 'h ' if hours > 0 else ''}{str(minutes) + 'm ' if minutes > 0 else ''}{seconds}s"
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"You already claimed your daily reward today!{sep}Come back in `{description}`!",
description=f"You already claimed your daily reward today!{sep}Come back in `{str(days)+'d ' if days > 0 else ''}{str(hours) + 'h ' if hours > 0 else ''}{str(minutes) + 'm ' if minutes > 0 else ''}{str(seconds) + 's' if seconds > 0 else ''}`!",
color="#dc3545"
)
return await ctx.reply(embed=embed)
Expand Down
32 changes: 18 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,21 @@ async def serverupdate():
import time

async def upd():
for i in (await userdb.find({})):
userdb.bulk_write(
[
pymongo.UpdateOne(
{'userid':i['userid']},
{'$set':
{
"status.afk": {}
doc = await userdb.find({}).to_list(length=None)
for i in doc:
await userdb.bulk_write(
[
pymongo.UpdateOne(
{'userid':i['userid']},
{'$set':
{
"economy.monthly": time.time()
}
}
}
),
]
)
print(f"Updated {i['username']}!")
),
]
)
print(f"Updated {i['username']}!")


async def update_level(user:voltage.User):
Expand Down Expand Up @@ -271,6 +272,8 @@ async def add_user(user: voltage.User, isbot:bool=False): # long ass fucking fun
"wallet": 0,
"bank": 0,
"total": 0,
"daily": time.time(),
"monthly": time.time(),
"data": {
"inventory": {
"Bank Loan": 1
Expand Down Expand Up @@ -307,7 +310,8 @@ async def add_user(user: voltage.User, isbot:bool=False): # long ass fucking fun
"beta": False,
"familyfriendly": False,
"isBot": isbot,
"banned": False
"banned": False,
"afk": {}
}
})
return "Added"
Expand Down

0 comments on commit 709a87c

Please sign in to comment.