|
1 | 1 | # Modules |
2 | | -import random |
3 | 2 | import discord |
| 3 | +from random import randint |
4 | 4 |
|
5 | 5 | from json import loads, dumps |
6 | | - |
7 | 6 | from discord.ext import commands |
| 7 | + |
8 | 8 | from assets.prism import Cooldowns, Tools |
9 | 9 |
|
10 | 10 | # Main Command Class |
@@ -37,98 +37,42 @@ async def rob(self, ctx, user = None): |
37 | 37 | return await ctx.send(embed = Tools.error("Stop trying to rob me.")) |
38 | 38 |
|
39 | 39 | db = loads(open("db/users", "r").read()) |
40 | | - |
| 40 | + |
41 | 41 | if not str(user.id) in db: |
42 | | - |
| 42 | + |
43 | 43 | return await ctx.send(embed = Tools.error(f"{user.name} doesn't have an account.")) |
44 | | - |
45 | | - victim = db[str(user.id)] |
46 | | - |
47 | | - author = db[str(ctx.author.id)] |
48 | | - |
49 | | - if victim["balance"] < 100: |
50 | | - |
51 | | - return await ctx.send(embed = Tools.error(f"{user.name} doesn't even have 100 coins.")) |
52 | | - |
53 | | - elif Tools.has_flag(db, user, "protected"): |
54 | | - |
55 | | - return await ctx.send(embed = Tools.error(f"{user.name} has a Bank Lock active.")) |
56 | 44 |
|
57 | | - if random.randint(1, 3) == 1: |
58 | | - |
59 | | - fine = random.randint(75, 310) |
60 | | - |
61 | | - author["balance"] -= fine |
62 | | - |
63 | | - open("db/users", "w").write(dumps(db, indent = 4)) |
64 | | - |
65 | | - await ctx.send(embed = Tools.error(f"You got busted and were fined {fine} coins.")) |
| 45 | + elif db[str(user.id)]["balance"] < 500: |
66 | 46 |
|
67 | | - return await Cooldowns.set_cooldown(ctx, "rob", 3600) |
68 | | - |
69 | | - number = random.randint(1, 5) |
70 | | - |
71 | | - if number == 1: |
72 | | - |
73 | | - author["balance"] += victim["balance"] |
74 | | - |
75 | | - bal = victim["balance"] |
| 47 | + return await ctx.send(embed = Tools.error(f"Bruh, {user.name} is poor.")) |
76 | 48 |
|
77 | | - victim["balance"] = 0 |
| 49 | + elif db[str(ctx.author.id)]["balance"] < 300: |
78 | 50 |
|
79 | | - embed = discord.Embed(title = f"You just robbed {user.name} for {bal} coins and made them go broke.", color = 0x126bf1) |
80 | | - |
81 | | - embed.set_author(name = " | Rob", icon_url = self.bot.user.avatar_url) |
82 | | - |
83 | | - embed.set_footer(text = f" | Robbed by {ctx.author}.", icon_url = ctx.author.avatar_url) |
84 | | - |
85 | | - elif number in range(2, 4): |
86 | | - |
87 | | - author["balance"] += round((victim["balance"] / 3) * 2) |
| 51 | + return await ctx.send(embed = Tools.error("You need at least 300 coins to rob someone.")) |
88 | 52 |
|
89 | | - bal = victim["balance"] |
| 53 | + elif randint(0, 1): |
90 | 54 |
|
91 | | - victim["balance"] -= round((victim["balance"] / 3) * 2) |
92 | | - |
93 | | - embed = discord.Embed(title = f"You just robbed {user.name} for {round((bal / 3) * 2)} coins.", color = 0x126bf1) |
94 | | - |
95 | | - embed.set_author(name = " | Rob", icon_url = self.bot.user.avatar_url) |
96 | | - |
97 | | - embed.set_footer(text = f" | Robbed by {ctx.author}.", icon_url = ctx.author.avatar_url) |
| 55 | + # user wins |
| 56 | + earn = randint(250, round(db[str(user.id)]["balance"] / 2)) |
98 | 57 |
|
99 | | - else: |
100 | | - |
101 | | - author["balance"] += round(victim["balance"] / 3) |
| 58 | + db[str(user.id)]["balance"] -= earn |
102 | 59 |
|
103 | | - bal = victim["balance"] |
| 60 | + db[str(ctx.author.id)]["balance"] += earn |
104 | 61 |
|
105 | | - victim["balance"] -= round(victim["balance"] / 3) |
106 | | - |
107 | | - embed = discord.Embed(title = f"You just robbed {user.name} for {round(bal / 3)} coins.", color = 0x126bf1) |
108 | | - |
109 | | - embed.set_author(name = " | Rob", icon_url = self.bot.user.avatar_url) |
110 | | - |
111 | | - embed.set_footer(text = f" | Robbed by {ctx.author}.", icon_url = ctx.author.avatar_url) |
| 62 | + embed = discord.Embed(title = "Nice :ok_hand:", description = f"You just robbed {user.name} and earned `{earn}` coins.", color = 0x126bf1) |
112 | 63 |
|
113 | | - try: |
| 64 | + else: |
114 | 65 |
|
115 | | - await ctx.send(embed = embed) |
116 | | - |
117 | | - except: |
| 66 | + # caught |
| 67 | + fee = randint(300, round(db[str(ctx.author.id)]["balance"] / 2)) |
118 | 68 |
|
119 | | - if number == 1: |
| 69 | + db[str(ctx.author.id)]["balance"] -= fee |
120 | 70 |
|
121 | | - embed = discord.Embed(title = f"You just robbed {user.name} for their whole wallet.", color = 0x126bf1) |
122 | | - |
123 | | - else: |
| 71 | + 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) |
124 | 72 |
|
125 | | - embed = discord.Embed(title = f"You just robbed {user.name} for ∞ coins.", color = 0x126bf1) |
126 | | - |
127 | | - embed.set_author(name = " | Rob", icon_url = self.bot.user.avatar_url) |
128 | | - |
129 | | - embed.set_footer(text = f" | Robbed by {ctx.author}.", icon_url = ctx.author.avatar_url) |
| 73 | + embed.set_author(name = " | Rob", icon_url = self.bot.user.avatar_url) |
130 | 74 |
|
131 | | - await ctx.send(embed = embed) |
| 75 | + embed.set_footer(text = " | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) |
132 | 76 |
|
133 | 77 | open("db/users", "w").write(dumps(db, indent = 4)) |
134 | 78 |
|
|
0 commit comments