Spaces:
Paused
Paused
Update petroll.py
Browse files- petroll.py +40 -49
petroll.py
CHANGED
|
@@ -13,6 +13,7 @@ luck_opportunities = {}
|
|
| 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):
|
|
@@ -193,7 +194,7 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 193 |
auto_roll_users.add(user_id)
|
| 194 |
auto_roll_button.style = discord.ButtonStyle.danger
|
| 195 |
auto_roll_button.label = "Stop Auto Roll"
|
| 196 |
-
await interaction.response.send_message("Auto roll started.", ephemeral=True)
|
| 197 |
asyncio.create_task(auto_roll(interaction))
|
| 198 |
|
| 199 |
await interaction.message.edit(view=view)
|
|
@@ -201,6 +202,37 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 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):
|
|
@@ -247,7 +279,13 @@ async def schedule_next_luck_opportunity(interaction: discord.Interaction, user_
|
|
| 247 |
|
| 248 |
async def auto_roll(interaction: discord.Interaction):
|
| 249 |
user_id = interaction.user.id
|
|
|
|
| 250 |
while user_id in auto_roll_users:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
result = await perform_roll(interaction)
|
| 252 |
if result:
|
| 253 |
await interaction.followup.send(embed=result[0], view=result[1])
|
|
@@ -275,51 +313,4 @@ 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 |
-
|
| 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_
|
|
|
|
| 13 |
used_luck_opportunities = {}
|
| 14 |
first_luck_claimed = set()
|
| 15 |
auto_roll_users = set()
|
| 16 |
+
auto_sell_users = set()
|
| 17 |
|
| 18 |
async def perform_roll(interaction: discord.Interaction):
|
| 19 |
async def fetch_data(url):
|
|
|
|
| 194 |
auto_roll_users.add(user_id)
|
| 195 |
auto_roll_button.style = discord.ButtonStyle.danger
|
| 196 |
auto_roll_button.label = "Stop Auto Roll"
|
| 197 |
+
await interaction.response.send_message("Auto roll started. It will automatically stop after 3 minutes.", ephemeral=True)
|
| 198 |
asyncio.create_task(auto_roll(interaction))
|
| 199 |
|
| 200 |
await interaction.message.edit(view=view)
|
|
|
|
| 202 |
auto_roll_button.callback = auto_roll_callback
|
| 203 |
view.add_item(auto_roll_button)
|
| 204 |
|
| 205 |
+
auto_sell_button = discord.ui.Button(
|
| 206 |
+
style=discord.ButtonStyle.primary if user_id not in auto_sell_users else discord.ButtonStyle.danger,
|
| 207 |
+
label="Auto Pet Sell" if user_id not in auto_sell_users else "Stop Auto Pet Sell",
|
| 208 |
+
custom_id="auto_pet_sell"
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
async def auto_sell_callback(interaction: discord.Interaction):
|
| 212 |
+
if interaction.user.id != user_id:
|
| 213 |
+
await interaction.response.send_message("You cannot use this button.", ephemeral=True)
|
| 214 |
+
return
|
| 215 |
+
|
| 216 |
+
if user_id in auto_sell_users:
|
| 217 |
+
auto_sell_users.remove(user_id)
|
| 218 |
+
auto_sell_button.style = discord.ButtonStyle.primary
|
| 219 |
+
auto_sell_button.label = "Auto Pet Sell"
|
| 220 |
+
await interaction.response.send_message("Auto pet sell stopped.", ephemeral=True)
|
| 221 |
+
else:
|
| 222 |
+
auto_sell_users.add(user_id)
|
| 223 |
+
auto_sell_button.style = discord.ButtonStyle.danger
|
| 224 |
+
auto_sell_button.label = "Stop Auto Pet Sell"
|
| 225 |
+
await interaction.response.send_message("Auto pet sell started.", ephemeral=True)
|
| 226 |
+
|
| 227 |
+
await interaction.message.edit(view=view)
|
| 228 |
+
|
| 229 |
+
auto_sell_button.callback = auto_sell_callback
|
| 230 |
+
view.add_item(auto_sell_button)
|
| 231 |
+
|
| 232 |
+
if user_id in auto_sell_users:
|
| 233 |
+
user_cash[user_id] = user_cash.get(user_id, 0) + rap_value
|
| 234 |
+
embed.add_field(name="Auto Sell", value=f"Pet automatically sold for ${rap_value}. New balance: ${user_cash[user_id]}", inline=False)
|
| 235 |
+
|
| 236 |
return embed, view
|
| 237 |
|
| 238 |
async def schedule_next_luck_opportunity(interaction: discord.Interaction, user_id: int):
|
|
|
|
| 279 |
|
| 280 |
async def auto_roll(interaction: discord.Interaction):
|
| 281 |
user_id = interaction.user.id
|
| 282 |
+
start_time = time.time()
|
| 283 |
while user_id in auto_roll_users:
|
| 284 |
+
if time.time() - start_time >= 180: # 3 minutes
|
| 285 |
+
auto_roll_users.remove(user_id)
|
| 286 |
+
await interaction.followup.send("Auto roll has been automatically stopped after 3 minutes. You can start it again if you wish.", ephemeral=True)
|
| 287 |
+
break
|
| 288 |
+
|
| 289 |
result = await perform_roll(interaction)
|
| 290 |
if result:
|
| 291 |
await interaction.followup.send(embed=result[0], view=result[1])
|
|
|
|
| 313 |
await roll_dice(interaction, bet)
|
| 314 |
|
| 315 |
async def roll_dice(interaction: discord.Interaction, bet: int):
|
| 316 |
+
user_i
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|