Spaces:
Building
Building
Update petroll.py
Browse files- petroll.py +58 -48
petroll.py
CHANGED
@@ -13,8 +13,6 @@ luck_opportunities = {}
|
|
13 |
used_luck_opportunities = {}
|
14 |
first_luck_claimed = set()
|
15 |
auto_roll_users = set()
|
16 |
-
auto_sell_users = set()
|
17 |
-
auto_sell_timers = {}
|
18 |
|
19 |
async def perform_roll(interaction: discord.Interaction):
|
20 |
async def fetch_data(url):
|
@@ -203,45 +201,6 @@ async def perform_roll(interaction: discord.Interaction):
|
|
203 |
auto_roll_button.callback = auto_roll_callback
|
204 |
view.add_item(auto_roll_button)
|
205 |
|
206 |
-
auto_sell_button = discord.ui.Button(
|
207 |
-
style=discord.ButtonStyle.primary if user_id not in auto_sell_users else discord.ButtonStyle.danger,
|
208 |
-
label="Auto Sell" if user_id not in auto_sell_users else "Stop Auto Sell",
|
209 |
-
custom_id="auto_sell"
|
210 |
-
)
|
211 |
-
|
212 |
-
async def auto_sell_callback(interaction: discord.Interaction):
|
213 |
-
if interaction.user.id != user_id:
|
214 |
-
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
215 |
-
return
|
216 |
-
|
217 |
-
current_time = time.time()
|
218 |
-
if user_id in auto_sell_timers and current_time - auto_sell_timers[user_id] < 180:
|
219 |
-
remaining_time = int(180 - (current_time - auto_sell_timers[user_id]))
|
220 |
-
await interaction.response.send_message(f"You need to wait {remaining_time} seconds before using Auto Sell again.", ephemeral=True)
|
221 |
-
return
|
222 |
-
|
223 |
-
if user_id in auto_sell_users:
|
224 |
-
auto_sell_users.remove(user_id)
|
225 |
-
auto_sell_button.style = discord.ButtonStyle.primary
|
226 |
-
auto_sell_button.label = "Auto Sell"
|
227 |
-
await interaction.response.send_message("Auto sell stopped.", ephemeral=True)
|
228 |
-
else:
|
229 |
-
auto_sell_users.add(user_id)
|
230 |
-
auto_sell_button.style = discord.ButtonStyle.danger
|
231 |
-
auto_sell_button.label = "Stop Auto Sell"
|
232 |
-
auto_sell_timers[user_id] = current_time
|
233 |
-
await interaction.response.send_message("Auto sell started for 3 minutes.", ephemeral=True)
|
234 |
-
asyncio.create_task(auto_sell_timer(interaction, user_id))
|
235 |
-
|
236 |
-
await interaction.message.edit(view=view)
|
237 |
-
|
238 |
-
auto_sell_button.callback = auto_sell_callback
|
239 |
-
view.add_item(auto_sell_button)
|
240 |
-
|
241 |
-
if user_id in auto_sell_users:
|
242 |
-
user_cash[user_id] = user_cash.get(user_id, 0) + rap_value
|
243 |
-
await interaction.followup.send(f"Auto-sold pet for ${rap_value}. Your new balance is ${user_cash[user_id]}.", ephemeral=True)
|
244 |
-
|
245 |
return embed, view
|
246 |
|
247 |
async def schedule_next_luck_opportunity(interaction: discord.Interaction, user_id: int):
|
@@ -296,12 +255,6 @@ async def auto_roll(interaction: discord.Interaction):
|
|
296 |
await interaction.followup.send("An error occurred.")
|
297 |
await asyncio.sleep(5) # Wait for 5 seconds between rolls
|
298 |
|
299 |
-
async def auto_sell_timer(interaction: discord.Interaction, user_id: int):
|
300 |
-
await asyncio.sleep(180) # Wait for 3 minutes
|
301 |
-
if user_id in auto_sell_users:
|
302 |
-
auto_sell_users.remove(user_id)
|
303 |
-
await interaction.followup.send("Auto sell has been turned off after 3 minutes.", ephemeral=True)
|
304 |
-
|
305 |
@app_commands.command(name="petroll", description="Roll for a random pet")
|
306 |
async def petroll(interaction: discord.Interaction):
|
307 |
await interaction.response.defer()
|
@@ -312,4 +265,61 @@ async def petroll(interaction: discord.Interaction):
|
|
312 |
await interaction.followup.send("An error occurred.")
|
313 |
|
314 |
@app_commands.command(name="balance", description="Check your current balance")
|
315 |
-
async def balance(interaction: discord.Interaction):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
used_luck_opportunities = {}
|
14 |
first_luck_claimed = set()
|
15 |
auto_roll_users = set()
|
|
|
|
|
16 |
|
17 |
async def perform_roll(interaction: discord.Interaction):
|
18 |
async def fetch_data(url):
|
|
|
201 |
auto_roll_button.callback = auto_roll_callback
|
202 |
view.add_item(auto_roll_button)
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
return embed, view
|
205 |
|
206 |
async def schedule_next_luck_opportunity(interaction: discord.Interaction, user_id: int):
|
|
|
255 |
await interaction.followup.send("An error occurred.")
|
256 |
await asyncio.sleep(5) # Wait for 5 seconds between rolls
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
@app_commands.command(name="petroll", description="Roll for a random pet")
|
259 |
async def petroll(interaction: discord.Interaction):
|
260 |
await interaction.response.defer()
|
|
|
265 |
await interaction.followup.send("An error occurred.")
|
266 |
|
267 |
@app_commands.command(name="balance", description="Check your current balance")
|
268 |
+
async def balance(interaction: discord.Interaction):
|
269 |
+
user_id = interaction.user.id
|
270 |
+
current_balance = user_cash.get(user_id, 0)
|
271 |
+
await interaction.response.send_message(f"Your current balance is ${current_balance}.", ephemeral=True)
|
272 |
+
|
273 |
+
@app_commands.command(name="dice", description="Roll the dice and bet")
|
274 |
+
async def dice(interaction: discord.Interaction, bet: int):
|
275 |
+
await roll_dice(interaction, bet)
|
276 |
+
|
277 |
+
async def roll_dice(interaction: discord.Interaction, bet: int):
|
278 |
+
user_id = interaction.user.id
|
279 |
+
balance = user_cash.get(user_id, 0)
|
280 |
+
|
281 |
+
if bet <= 0:
|
282 |
+
await interaction.response.send_message("Bet Higher than 0 Idiot.")
|
283 |
+
return
|
284 |
+
|
285 |
+
if bet > balance:
|
286 |
+
await interaction.response.send_message(f"You don't have enough cash. Your current balance is ${balance:.2f}")
|
287 |
+
return
|
288 |
+
|
289 |
+
embed = discord.Embed(title="Dice Roll", description=f"{interaction.user.name} is betting ${bet:.2f}", color=0x787878)
|
290 |
+
embed.add_field(name="Current Balance", value=f"${balance:.2f}", inline=False)
|
291 |
+
|
292 |
+
roll_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll the Dice", custom_id="roll_dice")
|
293 |
+
|
294 |
+
async def roll_dice_callback(interaction: discord.Interaction):
|
295 |
+
nonlocal balance
|
296 |
+
result = random.choice(["win", "lose"])
|
297 |
+
|
298 |
+
if result == "win":
|
299 |
+
winnings = bet
|
300 |
+
balance += winnings
|
301 |
+
result_text = f"You won ${winnings:.2f}!"
|
302 |
+
else:
|
303 |
+
balance -= bet
|
304 |
+
result_text = f"You lost ${bet:.2f}."
|
305 |
+
|
306 |
+
user_cash[user_id] = balance
|
307 |
+
|
308 |
+
embed.clear_fields()
|
309 |
+
embed.add_field(name="Result", value=result_text, inline=False)
|
310 |
+
embed.add_field(name="New Balance", value=f"${balance:.2f}", inline=False)
|
311 |
+
|
312 |
+
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
313 |
+
|
314 |
+
async def roll_again_callback(interaction: discord.Interaction):
|
315 |
+
if interaction.user.id == user_id:
|
316 |
+
await roll_dice(interaction, bet)
|
317 |
+
else:
|
318 |
+
await interaction.response.send_message("you cant roll this", ephemeral=True)
|
319 |
+
|
320 |
+
roll_again_button.callback = roll_again_callback
|
321 |
+
|
322 |
+
new_view = discord.ui.View()
|
323 |
+
new_view.add_item(roll_again_button)
|
324 |
+
|
325 |
+
await interaction.response.edit_
|