Skip to content

Commit

Permalink
fix: bank_loan into the more professional Bank Loan
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Mar 26, 2024
1 parent 2d0ba3f commit b8612c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ async def useitem(ctx, item:str, amount:str="1"):
amt = (random.randint(500, 1000) * user["levels"]["level"]) * round(am)

await userdb.bulk_write([
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.data.inventory.playboy": -1}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.data.inventory.playboy": -int(am)}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": round(amt)}}),
])
embed = voltage.SendableEmbed(
Expand All @@ -1288,7 +1288,7 @@ async def useitem(ctx, item:str, amount:str="1"):
if any(x in i for x in ["bank_loan", "Bank Loan"]) > 0: # Check if the item is in the inventory
amt = (random.randint(10000, 50000) * user["levels"]["level"]) * round(am)
await userdb.bulk_write([
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.data.inventory.Bank Loan": -1}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.data.inventory.Bank Loan": -int(am)}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": amt}}),
])
embed = voltage.SendableEmbed(
Expand Down
25 changes: 12 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,18 @@ async def serverupdate():
async def upd():
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']}!")
try:
if i['economy']['data']['inventory']['bank_loan']:
bank = i['economy']['data']['inventory']['bank_loan']
await userdb.update_one({'userid': i['userid']}, {'$unset': {'economy.data.inventory.bank_loan': 1}})
if bank < 0:
bank = 0
await userdb.update_one({'userid': i['userid']}, {'$set': {'economy.data.inventory.Bank Loan': bank}})
print(f"Added {bank} bank notes to {i['username']}")
except KeyError:
pass




async def update_level(user:voltage.User):
Expand Down

0 comments on commit b8612c1

Please sign in to comment.