Skip to content

Commit

Permalink
i dont even remember what i did but yeah ehre you go
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Mar 15, 2024
1 parent d15bdc4 commit 565108a
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 17 deletions.
121 changes: 109 additions & 12 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,21 @@ async def parse_amount(ctx, amount, bank=False):
return None


async def buy_item(ctx, item:str, price:int): # this sucks but it works
async def buy_item(ctx, item:str, price:int, amount:int): # this sucks but it works
if (await userdb.find_one({"userid": ctx.author.id})):
if amount < 1:
return await ctx.reply("Amount must be greater than 0!")
userdata = (await userdb.find_one({"userid": ctx.author.id}))
if userdata['economy']['wallet'] < price:
return await ctx.reply("You don't have enough money to purchase this!")
if item in userdata['economy']['data']['inventory']:
await userdb.bulk_write([
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": -price}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {f"economy.data.inventory.{item.lower()}": 1}})
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {f"economy.data.inventory.{item.lower()}": amount}})
])
else:
await userdb.bulk_write([
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {f"economy.data.inventory.{item.lower()}": 1}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {f"economy.data.inventory.{item.lower()}": amount}}),
pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": -price}})
])
return await ctx.reply(f"You bought **{item.capitalize()}** for **{price}** coins!")
Expand Down Expand Up @@ -310,9 +312,10 @@ async def bal(ctx, user:voltage.User=None):
async def beg(ctx):
amount = random.randint(1, 250)
people = [
"Jan From Revolt",
"Lea From Revolt",
"ks",
"Cesiyi",
"css",
"Fatal From Revolt",
"Delta2571",
"Rick Astley",
Expand Down Expand Up @@ -374,7 +377,6 @@ async def beg(ctx):
"Flo from Progressive",
"That tiktok star that shows a little too much butt",
"Sir Cole Jerkin",
"T series",
"Jennifer Lopez",
"Barack Obama",
"Cersei Lannister",
Expand All @@ -388,10 +390,10 @@ async def beg(ctx):
"Mr. Beast",
"Annoying Ass Clown",
"That lion from the kids movie that vaguely resembles the story of Jesus Christ",
"That imposter who was too scared to murder you just because he didn't want to look sus",
"TikTok Moron",
"Alotta Fagina",
"Joe",
"Max",

This comment has been minimized.

Copy link
@theycallhermax
]
badline = [
"be gone",
Expand Down Expand Up @@ -434,7 +436,7 @@ async def beg(ctx):
percentage = random.randint(1, 100)
if not (await userdb.find_one({"userid": ctx.author.id})):
await create_account(ctx)
if random.randint(1,200) == 1 or ctx.author.display_name.lower() == "mechahater":
elif random.randint(1,200) == 1 or ctx.author.display_name.lower() == "mechahater":
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
Expand All @@ -446,7 +448,7 @@ async def beg(ctx):
{"$set": {"economy.wallet": 0}},
)
return await ctx.reply(embed=embed)
if percentage > 25:
elif percentage > 25:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
Expand Down Expand Up @@ -1042,7 +1044,7 @@ async def job(ctx, job=None):

@eco.command(aliases=["sh", "buy"], description="Buy items from the shop!", name="shop")
@limiter(5, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please try again in `{strfdelta(datetime.timedelta(seconds=delay), '{seconds}s')}`!"))
async def shop(ctx, item:str=None):
async def shop(ctx, item:str=None, amount:int=1):
if not item:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
Expand All @@ -1069,7 +1071,7 @@ async def shop(ctx, item:str=None):
"form",
"resueme",
]):
await buy_item(ctx, "Resume", 250)
await buy_item(ctx, "Resume", 250, amount)
elif any(x in item.lower() for x in [
"gedd",
"gegg",
Expand All @@ -1080,7 +1082,7 @@ async def shop(ctx, item:str=None):
"egg",
"ge",
]):
await buy_item(ctx, "Golden Egg", 5000)
await buy_item(ctx, "Golden Egg", 5000, amount)
elif any(x in item.lower() for x in [
"pb",
"playboi",
Expand All @@ -1090,7 +1092,7 @@ async def shop(ctx, item:str=None):
"playb",
"pboy",
]):
await buy_item(ctx, "Playboy", 1000)
await buy_item(ctx, "Playboy", 1000, amount)
else:
await create_account(ctx)

Expand Down Expand Up @@ -1201,4 +1203,99 @@ async def slots(ctx, amount: str):
if (await userdb.find_one({"userid": ctx.author.id})) is None:
await create_account(ctx)


unusable_items = ["resume"] # Add more items if needed

async def useitem(ctx, item:str, amount:str="1"):
am = int(await parse_amount(ctx, amount))
if am < 1:
embed = voltage.SendableEmbed(
title="Error",
description="Invalid amount specified. Please specify an amount like `100` or `1k` or `1m`",
color="#FF0000"
)
return await ctx.reply(embed=embed)
user = await userdb.find_one({"userid": ctx.author.id})
if user is None:
embed = voltage.SendableEmbed(
title="Error",
description="You dont have a bank account registered in our database! Would you like me to create one?",
color="#FF0000",
)
return await ctx.send(embed=embed)
items = user["economy"]["data"]["inventory"]
if item not in items:
embed = voltage.SendableEmbed(
title="Error",
description=f"You don't have {item}!",
color="#FF0000",
)
return await ctx.send(embed=embed)
elif items[item] < 1:
embed = voltage.SendableEmbed(
title="Error",
description=f"You don't have enough {item}!",
color="#FF0000",
)
return await ctx.send(embed=embed)
elif item in unusable_items:
embed = voltage.SendableEmbed(
title="Error",
description=f"You can't use {item}!",
color="#FF0000",
)
return await ctx.send(embed=embed)

# check what the item is
if item == "playboy":
if user["economy"]["data"]["inventory"]["playboy"] < 1:
embed = voltage.SendableEmbed(
title="Error",
description=f"You don't have any {item}!",
color="#FF0000",
)
return await ctx.reply(embed=embed)
if random.randint(1, 100) < 90:
amt = (random.randint(1, 50) * user["levels"]["level"]) * round(am)
else:
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.wallet": round(amt)}}),
])
embed = voltage.SendableEmbed(
title="Success",
description=f"You used `x{round(am)}` **{item}**!{sep}You got ${round(amt):,} coins!",
color="#00FF00",
)
return await ctx.send(embed=embed)
elif item == "bank_loan" or item == "Bank Loan":
for i in user["economy"]["data"]["inventory"]:
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.wallet": amt}}),
])
embed = voltage.SendableEmbed(
title="Success",
description=f"You used `x{round(am)}` **{item}**!{sep}You got ${amt:,} coins!",
color="#00FF00",
)
return await ctx.send(embed=embed)
else:
embed = voltage.SendableEmbed(
title="Error",
description=f"You don't have any {item}!",
color="#FF0000",
)
return await ctx.reply(embed=embed)



@eco.command(name="use", description="Use an item.", aliases=["eat", "drink", "useitem"])
async def use(ctx, item, amount="1"):
await useitem(ctx, item, amount)

return eco
13 changes: 8 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,14 @@ async def oldlevelstuff(message): # running this in the on_message event drops t
print(await add_user(message))

async def loggingstuff(message):
if message.server.id == message.author.id:
return
else:
return await add_user(message.author)

try:
if message.server.id == message.author.id:
return
else:
return await add_user(message.author)
except:
pass

async def levelstuff(message):
try:
if message.content.startswith("<@01FZB4GBHDVYY6KT8JH4RBX4KR>"):
Expand Down

0 comments on commit 565108a

Please sign in to comment.