Spaces:
Building
Building
Update petroll.py
Browse files- petroll.py +12 -13
petroll.py
CHANGED
@@ -15,7 +15,6 @@ used_luck_opportunities = {}
|
|
15 |
first_luck_claimed = set()
|
16 |
auto_roll_users = set()
|
17 |
auto_sell_users = set()
|
18 |
-
can_manual_sell = set() # Tracks users who can perform a manual sell
|
19 |
|
20 |
async def perform_roll(interaction: discord.Interaction):
|
21 |
async def fetch_data(url):
|
@@ -84,7 +83,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
84 |
embed.set_footer(text=f"Click 'Roll Again' to roll again!{luck_text}")
|
85 |
|
86 |
# Create buttons
|
87 |
-
view = discord.ui.View()
|
88 |
|
89 |
# Roll Again Button
|
90 |
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
@@ -96,7 +95,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
96 |
await interaction.followup.send(embed=result[0], view=result[1])
|
97 |
else:
|
98 |
await interaction.followup.send("An error occurred.")
|
99 |
-
|
100 |
roll_again_button.callback = roll_again_callback
|
101 |
view.add_item(roll_again_button)
|
102 |
|
@@ -112,17 +111,15 @@ async def perform_roll(interaction: discord.Interaction):
|
|
112 |
user_cash[user_id] = user_cash.get(user_id, 0) + sell_value
|
113 |
await interaction.response.send_message(f"You sold the pet for ${sell_value}. Your new balance is ${user_cash[user_id]}.", ephemeral=True)
|
114 |
|
115 |
-
#
|
116 |
-
can_manual_sell.discard(user_id)
|
117 |
view.remove_item(sell_button)
|
118 |
await interaction.message.edit(view=view)
|
119 |
|
120 |
sell_button.callback = sell_pet_callback
|
121 |
|
122 |
-
# Add sell button only if auto-sell is not enabled
|
123 |
-
if user_id not in auto_sell_users
|
124 |
view.add_item(sell_button)
|
125 |
-
can_manual_sell.add(user_id)
|
126 |
|
127 |
# First Luck Button
|
128 |
if user_id not in first_luck_claimed:
|
@@ -224,10 +221,9 @@ async def perform_roll(interaction: discord.Interaction):
|
|
224 |
auto_sell_button.style = discord.ButtonStyle.primary
|
225 |
auto_sell_button.label = "Auto Pet Sell"
|
226 |
await interaction.response.send_message("Auto pet sell stopped.", ephemeral=True)
|
227 |
-
#
|
228 |
-
|
229 |
-
|
230 |
-
view.add_item(sell_button)
|
231 |
else:
|
232 |
auto_sell_users.add(user_id)
|
233 |
auto_sell_button.style = discord.ButtonStyle.danger
|
@@ -245,6 +241,9 @@ async def perform_roll(interaction: discord.Interaction):
|
|
245 |
if user_id in auto_sell_users:
|
246 |
user_cash[user_id] = user_cash.get(user_id, 0) + rap_value
|
247 |
embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
|
|
|
|
|
|
|
248 |
|
249 |
return embed, view
|
250 |
|
@@ -294,7 +293,7 @@ async def auto_roll(interaction: discord.Interaction):
|
|
294 |
while user_id in auto_roll_users:
|
295 |
if time.time() - start_time >= 180: # 3 minutes
|
296 |
auto_roll_users.remove(user_id)
|
297 |
-
await interaction.followup.send("auto roll stopped, to turn it on again roll
|
298 |
break
|
299 |
|
300 |
result = await perform_roll(interaction)
|
|
|
15 |
first_luck_claimed = set()
|
16 |
auto_roll_users = set()
|
17 |
auto_sell_users = set()
|
|
|
18 |
|
19 |
async def perform_roll(interaction: discord.Interaction):
|
20 |
async def fetch_data(url):
|
|
|
83 |
embed.set_footer(text=f"Click 'Roll Again' to roll again!{luck_text}")
|
84 |
|
85 |
# Create buttons
|
86 |
+
view = discord.ui.View(timeout=None)
|
87 |
|
88 |
# Roll Again Button
|
89 |
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
|
|
95 |
await interaction.followup.send(embed=result[0], view=result[1])
|
96 |
else:
|
97 |
await interaction.followup.send("An error occurred.")
|
98 |
+
|
99 |
roll_again_button.callback = roll_again_callback
|
100 |
view.add_item(roll_again_button)
|
101 |
|
|
|
111 |
user_cash[user_id] = user_cash.get(user_id, 0) + sell_value
|
112 |
await interaction.response.send_message(f"You sold the pet for ${sell_value}. Your new balance is ${user_cash[user_id]}.", ephemeral=True)
|
113 |
|
114 |
+
# Remove the sell button after selling to prevent duplicate sales
|
|
|
115 |
view.remove_item(sell_button)
|
116 |
await interaction.message.edit(view=view)
|
117 |
|
118 |
sell_button.callback = sell_pet_callback
|
119 |
|
120 |
+
# Add sell button only if auto-sell is not enabled
|
121 |
+
if user_id not in auto_sell_users:
|
122 |
view.add_item(sell_button)
|
|
|
123 |
|
124 |
# First Luck Button
|
125 |
if user_id not in first_luck_claimed:
|
|
|
221 |
auto_sell_button.style = discord.ButtonStyle.primary
|
222 |
auto_sell_button.label = "Auto Pet Sell"
|
223 |
await interaction.response.send_message("Auto pet sell stopped.", ephemeral=True)
|
224 |
+
# Re-add the sell button only if it's not already removed
|
225 |
+
if not any(item.custom_id == "sell_pet" for item 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
|
|
|
241 |
if user_id in auto_sell_users:
|
242 |
user_cash[user_id] = user_cash.get(user_id, 0) + rap_value
|
243 |
embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
|
244 |
+
# Remove the sell button since it's auto-sold
|
245 |
+
if any(item.custom_id == "sell_pet" for item in view.children):
|
246 |
+
view.remove_item(sell_button)
|
247 |
|
248 |
return embed, view
|
249 |
|
|
|
293 |
while user_id in auto_roll_users:
|
294 |
if time.time() - start_time >= 180: # 3 minutes
|
295 |
auto_roll_users.remove(user_id)
|
296 |
+
await interaction.followup.send("auto roll stopped, to turn it on again, roll again then turn it on", ephemeral=True)
|
297 |
break
|
298 |
|
299 |
result = await perform_roll(interaction)
|