coollsd commited on
Commit
db3ed0a
·
verified ·
1 Parent(s): bf9bbeb

Update petroll.py

Browse files
Files changed (1) hide show
  1. petroll.py +69 -66
petroll.py CHANGED
@@ -1,4 +1,4 @@
1
- ;import discord
2
  from discord import app_commands
3
  import aiohttp
4
  import random
@@ -117,6 +117,11 @@ async def perform_roll(interaction: discord.Interaction):
117
  sell_button.callback = sell_pet_callback
118
  view.add_item(sell_button)
119
 
 
 
 
 
 
120
  if user_id not in first_luck_claimed:
121
  first_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Claim 100% Luck Forever", custom_id="first_luck")
122
 
@@ -221,83 +226,81 @@ async def perform_roll(interaction: discord.Interaction):
221
  auto_sell_button.label = "Auto Pet Sell"
222
  await interaction.response.send_message("Auto pet sell stopped.", ephemeral=True)
223
 
224
- # Re-add the normal sell button when stopping auto-sell
225
- if sell_button not in view.children:
226
- view.add_item(sell_button)
 
 
227
  else:
228
  auto_sell_users.add(user_id)
229
  auto_sell_button.style = discord.ButtonStyle.danger
230
  auto_sell_button.label = "Stop Auto Pet Sell"
231
- await interaction.response.send_message("Auto pet sell started.", ephemeral=True)
 
 
 
232
 
233
- # Automatically add cash for the rolled pet when auto-sell is enabled
234
- user_cash[user_id] = user_cash.get(user_id, 0) + rap_value
235
- embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
236
 
237
- await interaction.message.edit(view=view)
238
 
239
- auto_sell_button.callback = auto_sell_callback
240
- view.add_item(auto_sell_button)
241
 
242
- return embed, view
243
 
244
- async def schedule_next_luck_opportunity(interaction: discord.Interaction, user_id: int):
245
- await asyncio.sleep(1800) # Wait for 30 minutes
246
- luck_opportunities[user_id] = luck_opportunities.get(user_id, 0) + 1
247
- increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id=f"increase_luck_{luck_opportunities[user_id]}")
248
-
249
- async def increase_luck_callback(interaction: discord.Interaction):
250
- if interaction.user.id != user_id:
251
- await interaction.response.send_message("You cannot use this button.", ephemeral=True)
252
- return
253
-
254
- if user_id in used_luck_opportunities and len(used_luck_opportunities[user_id]) >= 4:
255
- await interaction.response.send_message("You have already used all your luck opportunities.", ephemeral=True)
256
- return
257
 
258
- current_luck = luck_multipliers.get(user_id, 1)
259
- new_luck = min(current_luck + 1, 10)
260
- luck_multipliers[user_id] = new_luck
261
- luck_expiration[user_id] = time.time() + 1800
262
-
263
- if user_id not in used_luck_opportunities:
264
- used_luck_opportunities[user_id] = set()
265
- used_luck_opportunities[user_id].add(luck_opportunities[user_id])
266
-
267
- luck_percentage = (new_luck - 1) * 100
268
- await interaction.response.send_message(f"Your luck has been increased to {luck_percentage}% for 30 minutes!", ephemeral=True)
269
-
270
- view = interaction.message.components[0]
271
- for item in view.children:
272
- if item.custom_id == interaction.custom_id:
273
- view.remove_item(item)
274
- break
275
- await interaction.message.edit(view=view)
276
 
277
- # Schedule the next luck opportunity
278
- asyncio.create_task(schedule_next_luck_opportunity(interaction, user_id))
279
-
280
- increase_luck_button.callback = increase_luck_callback
281
-
282
- view = interaction.message.components[0]
283
- view.add_item(increase_luck_button)
284
- await interaction.message.edit(view=view)
285
 
286
- async def auto_roll(interaction: discord.Interaction):
287
- user_id = interaction.user.id
288
- start_time = time.time()
289
- while user_id in auto_roll_users:
290
- if time.time() - start_time >= 180: # 3 minutes
291
- auto_roll_users.remove(user_id)
292
- await interaction.followup.send("auto roll stopped, to turn it on again roll again and turn it on.", ephemeral=True)
293
- break
294
-
295
- result = await perform_roll(interaction)
296
- if result:
297
- await interaction.followup.send(embed=result[0], view=result[1])
298
- else:
299
- await interaction.followup.send("An error occurred.")
300
- await asyncio.sleep(5) # Wait for 5 seconds between rolls
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
  @app_commands.command(name="petroll", description="Roll for a random pet")
303
  async def petroll(interaction: discord.Interaction):
 
1
+ import discord
2
  from discord import app_commands
3
  import aiohttp
4
  import random
 
117
  sell_button.callback = sell_pet_callback
118
  view.add_item(sell_button)
119
 
120
+ # Automatically process sale when auto-sell is active
121
+ if user_id in auto_sell_users:
122
+ user_cash[user_id] += rap_value
123
+ embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
124
+
125
  if user_id not in first_luck_claimed:
126
  first_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Claim 100% Luck Forever", custom_id="first_luck")
127
 
 
226
  auto_sell_button.label = "Auto Pet Sell"
227
  await interaction.response.send_message("Auto pet sell stopped.", ephemeral=True)
228
 
229
+ # Re-add the normal sell button when stopping auto-sell
230
+ sell_button.style=discord.ButtonStyle.success
231
+ sell_button.label=f"Sell Pet for ${rap_value}"
232
+ view.add_item(sell_button)
233
+
234
  else:
235
  auto_sell_users.add(user_id)
236
  auto_sell_button.style = discord.ButtonStyle.danger
237
  auto_sell_button.label = "Stop Auto Pet Sell"
238
+
239
+ # Automatically add cash and notify when starting auto-sell
240
+ user_cash[user_id] += rap_value
241
+ embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
242
 
243
+ await interaction.response.send_message(f"Auto pet sell started. Pet sold for ${rap_value}. New balance is ${user_cash[user_id]}.", ephemeral=True)
 
 
244
 
245
+ await interaction.message.edit(view=view)
246
 
247
+ auto_sell_button.callback=auto_sell_callback
248
+ view.add_item(auto_sell_button)
249
 
250
+ return embed, view
251
 
252
+ async def schedule_next_luck_opportunity(interaction:discord.Interaction,user id:int):
253
+ await asyncio.sleep(1800) # Wait for 30 minutes
254
+ luck_opportunities[user id]=luck_opportunities.get(user id,0)+1
255
+ increase_luck_button=discord.ui.Button(style=discord.ButtonStyle.success,label="Increase Luck",custom id=f"increase luck {luck opportunities[user id]}")
 
 
 
 
 
 
 
 
 
256
 
257
+ async def increase_luck_callback(interaction:discord.Interaction):
258
+ if interaction.user.id!=user id:
259
+ await interaction.response.send message("You cannot use this button.",ephemeral=True)
260
+ return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
+ if user id in used luck opportunities and len(used luck opportunities[user id])>=4:
263
+ await interaction.response.send message("You have already used all your luck opportunities.",ephemeral=True)
264
+ return
 
 
 
 
 
265
 
266
+ current luck=luck multipliers.get(user id,1)
267
+ new luck=min(current luck+1,10)
268
+ luck multipliers[user id]=new luck
269
+ luck expiration[user id]=time.time()+1800
270
+
271
+ if user id not in used luck opportunities:
272
+ used luck opportunities[user id]=set()
273
+ used luck opportunities[user id].add(luck opportunities[user id])
274
+
275
+ luck percentage=(new luck-1)*100
276
+ await interaction.response.send message(f"Your luck has been increased to {luck percentage}% for 30 minutes!",ephemeral=True)
277
+
278
+ view=interaction.message.components[0]
279
+ for item in view.children:
280
+ if item.custom id==interaction.custom id:
281
+ view.remove item(item)
282
+ break
283
+ await interaction.message.edit(view=view)
284
+
285
+ # Schedule the next luck opportunity
286
+ asyncio.create task(schedule next luck opportunity(interaction,user id))
287
+
288
+ increase.luck button.callback=increase.luck callback
289
+
290
+ view=interaction.message.components[0]
291
+ view.add item(increase.luck button)
292
+ await interaction.message.edit(view=view)
293
+
294
+ async def.auto roll(interaction:discord.Interaction):
295
+ user id=interaction.user.id
296
+ start time=time.time()
297
+ while useridinauto roll users:
298
+ if time.time()-start time>=180:#3minutes
299
+ autoroll users.remove(userid)
300
+ await.interaction.followup send("auto roll stopped, to auto roll again roll normally and start it",ephemeral=True) break
301
+
302
+ result=await.perform roll(interaction)
303
+ if result:await.interaction.followup send(embed=result[0],view=result[1])else:await.interaction.followup send("An error occurred.")await.asyncio.sleep(5)#Waitfor5secondsbetweenrolls
304
 
305
  @app_commands.command(name="petroll", description="Roll for a random pet")
306
  async def petroll(interaction: discord.Interaction):