async def beg(self, ctx, member: discord.User = None): user = choice(self.people) if randint(1, 10) == 1: user = "******" if member: member = await Tools.getClosestUser(ctx, member) user = member.name elif Cooldowns.on_cooldown(ctx, "beg"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "beg")) amount = randint(10, 75) db = loads(open("db/users", "r").read()) db[str(ctx.author.id)]["balance"] += amount embed = discord.Embed( title=f"You begged {user} for coins and gained {amount} coins.", color=0x126bf1) embed.set_author(name=" | Beg", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) open("db/users", "w").write(dumps(db, indent=4)) return await Cooldowns.set_cooldown(ctx, "beg", 60)
async def clearcooldowns(self, ctx, user: discord.User = None): if not user: user = ctx.author Cooldowns.clear_cooldown(user) embed = discord.Embed(title=f"{user}'s cooldowns have been cleared.", color=0x126bf1) return await ctx.send(embed=embed)
async def purchase(self, ctx, id, amount): id, db, items = str(id), loads(open("db/users", "r").read()), loads( open("assets/res/items.json", "r").read()) if not str(id) in items: return await ctx.send(embed=Tools.error("Invalid item ID!")) user = db[str(ctx.author.id)] item = items[id] if not user["balance"] >= item["price"]: return await ctx.send( embed=Tools.error("You don't have enough coins.")) elif "premium" in item[ "tags"] and not "premium" in user["data"]["tags"]: return await ctx.send( embed=Tools.error("You need premium to purchase that.")) elif ":" in item["name"]: if ">" in item["name"]: item["name"] = item["name"].split(">")[1] else: item["name"] = item["name"].split(":")[2] if item["name"].startswith(" "): item["name"] = item["name"][1:] if "banklock" in item["tags"]: if amount > 1: return await ctx.send( embed=Tools.error("You cannot buy more than 1 bank lock.")) for tag in item["tags"]: if tag.startswith("duration-"): duration = int(tag.split("duration-")[1]) if not "protected" in user["data"]["tags"]: user["data"]["tags"].append("protected") else: return await ctx.send( embed=Tools.error("You already have a bank lock active.")) self.save(db) await ctx.send(embed=Tools.bought(item["name"], 1)) await sleep(duration) user["data"]["tags"].remove("protected") self.save(db) elif item["name"] == "Cooldown Repellent": if amount > 1: return await ctx.send(embed=Tools.error( "You cannot buy more than 1 canister of cooldown repellent." )) for tag in item["tags"]: if tag.startswith("duration-"): duration = int(tag.split("duration-")[1]) if "Cooldown Repellent" in user["data"]["inventory"]: return await ctx.send(embed=Tools.error( "You already have some Cooldown Repllent.")) user["data"]["inventory"]["Cooldown Repellent"] = {"count": 1} await ctx.send(embed=Tools.bought("Cooldown Repellent", 1)) Cooldowns.clear_cooldown(ctx.author) self.save(db) await sleep(duration) user["data"]["inventory"].pop("Cooldown Repellent") self.save(db) else: c = 0 while c < amount: if not item["name"] in user["data"]["inventory"]: user["data"]["inventory"][item["name"]] = {"count": 0} elif user["data"]["inventory"][item["name"]]["count"] > 999: return await ctx.send(embed=Tools.error( "You have reached the maximum stack limit for that item." )) user["data"]["inventory"][item["name"]]["count"] += 1 c += 1 await ctx.send(embed=Tools.bought(item["name"], amount)) user["balance"] -= item["price"] * amount self.save(db)
async def sock(self, ctx, user: discord.User = None): if Cooldowns.on_cooldown(ctx, "sock"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "sock")) elif not user: return await ctx.send( embed=Tools.error("No user specified to sock.")) user = await Tools.getClosestUser(ctx, user) db = loads(open("db/users", "r").read()) if user.id == ctx.author.id: return await ctx.send( embed=Tools.error("Stop trying to sock yourself.")) elif not Tools.has_flag(db, ctx.author, "premium"): return await ctx.send( embed=Tools.error("You need premium to use this command.")) elif not str(user.id) in db: earnings = randint(0, 100) db[str(ctx.author.id)]["balance"] += earnings open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title= f"You just socked **{user.name}** so hard that they dropped **{earnings} coins**.", color=0x126bf1) embed.set_author(name=" | Sock", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Socked by the great {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "sock", 300) earnings = randint(0, 100) db[str(ctx.author.id)]["balance"] += earnings db[str(user.id)]["balance"] -= earnings open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title= f"You just socked **{user.name}** so hard that they dropped **{earnings} coins**.", color=0x126bf1) embed.set_author(name=" | Sock", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Socked by the great {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "sock", 300)
async def sue(self, ctx, user: discord.User = None, *, reason: str = None): if Cooldowns.on_cooldown(ctx, "sue"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "sue")) db = loads(open("db/users", "r").read()) if not user: return await ctx.send( embed=Tools.error("Bruh, who are you trying to sue?")) elif not str(user.id) in db: return await ctx.send(embed=Tools.error( f"{user.name} doesn't have a Prism bank account.")) elif user == ctx.author: return await ctx.send(embed=Tools.error("You cannot sue yourself.") ) default = f"{ctx.author.name} is suing {user.name}" if not reason: text = default + "." reason = "" else: text = default + " for:" embed = discord.Embed(title=text, description=reason, color=0x126bf1) await ctx.send(embed=embed) if randint(1, 3) == 1: fee = round(db[str(ctx.author.id)]["balance"] / randint(5, 8)) if fee == 0: embed = discord.Embed( title= "You're so poor that the opposing side dropped the charges.", color=0x126bf1) embed.set_author(name=" | Lawsuit Dropped", icon_url=self.bot.user.avatar_url) return await ctx.send(embed=embed) db[str(ctx.author.id)]["balance"] -= fee db[str(user.id)]["balance"] += fee open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title=f"You lost the lawsuit and payed {fee} coins.", description=f"I bet {user.name} is laughing so hard right now.", color=0x126bf1) return await ctx.send(embed=embed) else: success = randint(1300, 8275) db[str(user.id)]["balance"] -= success db[str(ctx.author.id)]["balance"] += success open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title=f"You won the lawsuit and gained {success} coins.", description="Well played.", color=0x126bf1) embed.set_author(name=" | Lawsuit", icon_url=self.bot.user.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "sue", 3600)
async def daily(self, ctx): if Cooldowns.on_cooldown(ctx, "daily"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "daily")) db = loads(open("db/users", "r").read()) try: redeem = round(db[str(ctx.author.id)]["balance"] / 4) except: db[str(ctx.author.id)]["balance"] += 1000000000 open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title= f"You have redeemed ∞ daily coins.\n( Because your too rich for division ;) )", color=0x126bf1) embed.set_author(name=" | Daily", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "daily", 86400) if len(str(db[str(ctx.author.id)]["balance"])) > 50: db[str(ctx.author.id)]["balance"] += 1000000000 open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed( title= f"You have redeemed ∞ daily coins.\n( Because you're too rich for division ;) )", color=0x126bf1) embed.set_author(name=" | Daily", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "daily", 86400) db[str(ctx.author.id)]["balance"] += redeem if redeem == 0: redeem = 15 open("db/users", "w").write(dumps(db, indent=4)) embed = discord.Embed(title=f"You have redeemed {redeem} daily coins.", color=0x126bf1) embed.set_author(name=" | Daily", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "daily", 86400)
async def rob(self, ctx, user: discord.User = None): if Cooldowns.on_cooldown(ctx, "rob"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "rob")) elif not user: return await ctx.send( embed=Tools.error("Please specify somebody to rob.")) user = await Tools.getClosestUser(ctx, user) if user.id == ctx.author.id: return await ctx.send( embed=Tools.error("Stop trying to rob yourself.")) elif user.id == self.bot.user.id: return await ctx.send(embed=Tools.error("Stop trying to rob me.")) db = loads(open("db/users", "r").read()) if not str(user.id) in db: return await ctx.send( embed=Tools.error(f"{user.name} doesn't have an account.")) elif db[str(user.id)]["balance"] < 500: return await ctx.send( embed=Tools.error(f"Bruh, {user.name} is poor.")) elif db[str(ctx.author.id)]["balance"] < 300: return await ctx.send(embed=Tools.error( "You need at least 300 coins to rob someone.")) elif Tools.has_flag(db, user, "protected"): return await ctx.send( embed=Tools.error(f"{user.name} has a bank lock active.")) elif randint(0, 1): # user wins earn = randint(250, round(db[str(user.id)]["balance"] / 2)) db[str(user.id)]["balance"] -= earn db[str(ctx.author.id)]["balance"] += earn if len(str(earn)) > 15: earn = "∞" embed = discord.Embed( title="Nice :ok_hand:", description= f"You just robbed {user.name} and earned `{earn}` coins.", color=0x126bf1) else: # caught fee = randint(300, round(db[str(ctx.author.id)]["balance"] / 2)) db[str(ctx.author.id)]["balance"] -= fee embed = discord.Embed( title="L O L", description= f"You failed miserably at robbing {user.name} and got caught!!!111\nYou paid `{fee}` coins as a fee.", color=0xFF0000) embed.set_author(name=" | Rob", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) open("db/users", "w").write(dumps(db, indent=4)) await ctx.send(embed=embed) return await Cooldowns.set_cooldown(ctx, "rob", 3600)
async def bet(self, ctx, amount=None): if not amount: return await ctx.send( embed=Tools.error("No amount specified to bet.")) db = loads(open("db/users", "r").read()) try: amount = int(amount) if amount < 1: return await ctx.send( embed=Tools.error("Please enter a valid integer.")) except: if amount.lower() != "all": return await ctx.send(embed=Tools.error("That isn't a number.") ) amount = db[str(ctx.author.id)]["balance"] if len(str(amount)) > 50 and amount != db[str( ctx.author.id)]["balance"]: return await ctx.send( embed=Tools.error("That's way too much money.")) elif Cooldowns.on_cooldown(ctx, "bet"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "bet")) elif db[str(ctx.author.id)]["balance"] < amount: return await ctx.send(embed=Tools.error( f"You don't have {amount} coins in your account.")) elif randint(1, 2) == 1: db[str(ctx.author.id)]["balance"] += amount if len(str(amount)) > 50: amount = "∞" embed = discord.Embed(title=f"Darn, you win {amount} coins.", color=0x126bf1) embed.set_author(name=" | Bet", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) else: db[str(ctx.author.id)]["balance"] -= amount if len(str(amount)) > 50: amount = "∞" embed = discord.Embed(title=f"Ha, you lose {amount} coins.", color=0x126bf1) embed.set_author(name=" | Bet", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) open("db/users", "w").write(dumps(db, indent=4)) return await Cooldowns.set_cooldown(ctx, "bet", 60)
async def work(self, ctx): if Cooldowns.on_cooldown(ctx, "work"): return await ctx.send(embed = Cooldowns.cooldown_text(ctx, "work")) n1 = randint(1, 20) n2 = randint(1, 20) answer = n1 + n2 bot_msg = await ctx.send(f"You are now working; solve the equation: `{n1} + {n2}`.") db = loads(open("db/users", "r").read()) def check(m): return m.author == ctx.author and m.channel == ctx.channel try: message = await self.bot.wait_for("message", check = check, timeout = 5) except: earnings = randint(20, 100) db[str(ctx.author.id)]["balance"] += earnings open("db/users", "w").write(dumps(db, indent = 4)) return await ctx.send(embed = Tools.error(f"You didn't respond fast enough; but you still earned {earnings} coins.")) try: await bot_msg.delete() except: pass if not message.content.lower() == str(answer): earnings = randint(20, 100) db[str(ctx.author.id)]["balance"] += earnings open("db/users", "w").write(dumps(db, indent = 4)) await ctx.send(embed = Tools.error(f"You messed up at work; but you still earned {earnings} coins.")) return await Cooldowns.set_cooldown(ctx, "work", 600) reward = randint(200, 450) db[str(ctx.author.id)]["balance"] += reward open("db/users", "w").write(dumps(db, indent = 4)) embed = discord.Embed(title = f"Good job, you went to work and earned {reward} coins.", color = 0x126bf1) embed.set_author(name = " | Work", icon_url = self.bot.user.avatar_url) embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) await ctx.send(embed = embed) return await Cooldowns.set_cooldown(ctx, "work", 600)
async def vote(self, ctx): if Cooldowns.on_cooldown(ctx, "vote"): return await ctx.send(embed=Cooldowns.cooldown_text(ctx, "vote")) bot_data = loads( requests.get("https://top.gg/api/bots/685550504276787200", headers={ "Authorization": self.token }).text) base_upvotes = bot_data["points"] embed = discord.Embed( title="Click here to vote for Prism!", description="When your done, send a message in this channel.", url="https://top.gg/bot/685550504276787200/vote", color=0x126bf1) await ctx.send(embed=embed) def check(m): return m.author == ctx.author and m.channel == ctx.channel await self.bot.wait_for("message", check=check) embed = discord.Embed( title="This might take a few minutes.", description= "Since the top.gg API doesn't update instantly,\nit might take a minute to verify your vote.", color=0x126bf1) embed.set_author(name=" | Waiting for change", icon_url=self.bot.user.avatar_url) embed.set_footer(text=f" | Requested by {ctx.author}.", icon_url=ctx.author.avatar_url) message = await ctx.send(embed=embed) failed_attempts = 0 while failed_attempts < 16: bot_data = loads( requests.get("https://top.gg/api/bots/685550504276787200", headers={ "Authorization": self.token }).text) current_upvotes = bot_data["points"] if current_upvotes > base_upvotes: db = loads(open("db/users", "r").read()) db[str(ctx.author.id)]["balance"] = db[str( ctx.author.id)]["balance"] + 2750 open("db/users", "w").write(json.dumps(db, indent=4)) embed = discord.Embed( title="Thanks for voting!", description="Since you voted, you get a free $2,750.", color=0x0ee323) embed.set_author(name=" | Successful Vote", icon_url=self.bot.user.avatar_url) embed.set_footer(text=" | You can vote every 12 hours.", icon_url=ctx.author.avatar_url) try: await ctx.author.send(embed=embed) except: await ctx.send(embed=embed) try: await message.delete() except: pass if Tools.has_flag(db, ctx.author, "premium"): await Cooldowns.set_cooldown(ctx, "vote", 86400) break await Cooldowns.set_cooldown(ctx, "vote", 43200) break await sleep(15) failed_attempts += 1