Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ tree = app_commands.CommandTree(bot)
|
|
| 16 |
luck_multipliers = {}
|
| 17 |
luck_expiration = {}
|
| 18 |
luck_opportunities = {}
|
|
|
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
async def read_root():
|
|
@@ -192,6 +193,58 @@ async def petroll(interaction: discord.Interaction):
|
|
| 192 |
else:
|
| 193 |
await interaction.followup.send("errer")
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
@bot.event
|
| 196 |
async def on_ready():
|
| 197 |
await tree.sync()
|
|
|
|
| 16 |
luck_multipliers = {}
|
| 17 |
luck_expiration = {}
|
| 18 |
luck_opportunities = {}
|
| 19 |
+
user_cash = {}
|
| 20 |
|
| 21 |
@app.get("/")
|
| 22 |
async def read_root():
|
|
|
|
| 193 |
else:
|
| 194 |
await interaction.followup.send("errer")
|
| 195 |
|
| 196 |
+
@tree.command(name="cash", description="Check your current cash balance")
|
| 197 |
+
async def cash(interaction: discord.Interaction):
|
| 198 |
+
user_id = interaction.user.id
|
| 199 |
+
balance = user_cash.get(user_id, 0)
|
| 200 |
+
await interaction.response.send_message(f"Your current balance is ${balance:.2f}")
|
| 201 |
+
|
| 202 |
+
@tree.command(name="dice", description="Roll the dice and bet")
|
| 203 |
+
async def dice(interaction: discord.Interaction, bet: int):
|
| 204 |
+
user_id = interaction.user.id
|
| 205 |
+
balance = user_cash.get(user_id, 0)
|
| 206 |
+
|
| 207 |
+
if bet <= 0:
|
| 208 |
+
await interaction.response.send_message("Your bet must be greater than 0.")
|
| 209 |
+
return
|
| 210 |
+
|
| 211 |
+
if bet > balance:
|
| 212 |
+
await interaction.response.send_message(f"You don't have enough cash. Your current balance is ${balance:.2f}")
|
| 213 |
+
return
|
| 214 |
+
|
| 215 |
+
embed = discord.Embed(title="Dice Roll", description=f"{interaction.user.name} is betting ${bet:.2f}", color=0x00ff00)
|
| 216 |
+
embed.add_field(name="Current Balance", value=f"${balance:.2f}", inline=False)
|
| 217 |
+
|
| 218 |
+
roll_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll the Dice", custom_id="roll_dice")
|
| 219 |
+
|
| 220 |
+
async def roll_dice_callback(interaction: discord.Interaction):
|
| 221 |
+
nonlocal balance
|
| 222 |
+
result = random.choice(["win", "lose"])
|
| 223 |
+
|
| 224 |
+
if result == "win":
|
| 225 |
+
winnings = bet
|
| 226 |
+
balance += winnings
|
| 227 |
+
result_text = f"You won ${winnings:.2f}!"
|
| 228 |
+
else:
|
| 229 |
+
balance -= bet
|
| 230 |
+
result_text = f"You lost ${bet:.2f}."
|
| 231 |
+
|
| 232 |
+
user_cash[user_id] = balance
|
| 233 |
+
|
| 234 |
+
embed.clear_fields()
|
| 235 |
+
embed.add_field(name="Result", value=result_text, inline=False)
|
| 236 |
+
embed.add_field(name="New Balance", value=f"${balance:.2f}", inline=False)
|
| 237 |
+
|
| 238 |
+
view.clear_items()
|
| 239 |
+
await interaction.response.edit_message(embed=embed, view=view)
|
| 240 |
+
|
| 241 |
+
roll_button.callback = roll_dice_callback
|
| 242 |
+
|
| 243 |
+
view = discord.ui.View()
|
| 244 |
+
view.add_item(roll_button)
|
| 245 |
+
|
| 246 |
+
await interaction.response.send_message(embed=embed, view=view)
|
| 247 |
+
|
| 248 |
@bot.event
|
| 249 |
async def on_ready():
|
| 250 |
await tree.sync()
|