Spaces:
Running
Running
Update dice.py
Browse files
dice.py
CHANGED
|
@@ -6,6 +6,9 @@ from cash import user_cash
|
|
| 6 |
|
| 7 |
@app_commands.command(name="dice", description="Roll the dice and bet")
|
| 8 |
async def dice(interaction: discord.Interaction, bet: int):
|
|
|
|
|
|
|
|
|
|
| 9 |
user_id = interaction.user.id
|
| 10 |
balance = user_cash.get(user_id, 0)
|
| 11 |
|
|
@@ -17,7 +20,7 @@ async def dice(interaction: discord.Interaction, bet: int):
|
|
| 17 |
await interaction.response.send_message(f"You don't have enough cash. Your current balance is ${balance:.2f}")
|
| 18 |
return
|
| 19 |
|
| 20 |
-
embed = discord.Embed(title="Dice Roll", description=f"{interaction.user.name} is betting ${bet:.2f}", color=
|
| 21 |
embed.add_field(name="Current Balance", value=f"${balance:.2f}", inline=False)
|
| 22 |
|
| 23 |
roll_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll the Dice", custom_id="roll_dice")
|
|
@@ -41,7 +44,11 @@ async def dice(interaction: discord.Interaction, bet: int):
|
|
| 41 |
embed.add_field(name="New Balance", value=f"${balance:.2f}", inline=False)
|
| 42 |
|
| 43 |
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
new_view = discord.ui.View()
|
| 47 |
new_view.add_item(roll_again_button)
|
|
@@ -53,4 +60,7 @@ async def dice(interaction: discord.Interaction, bet: int):
|
|
| 53 |
view = discord.ui.View()
|
| 54 |
view.add_item(roll_button)
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@app_commands.command(name="dice", description="Roll the dice and bet")
|
| 8 |
async def dice(interaction: discord.Interaction, bet: int):
|
| 9 |
+
await roll_dice(interaction, bet)
|
| 10 |
+
|
| 11 |
+
async def roll_dice(interaction: discord.Interaction, bet: int):
|
| 12 |
user_id = interaction.user.id
|
| 13 |
balance = user_cash.get(user_id, 0)
|
| 14 |
|
|
|
|
| 20 |
await interaction.response.send_message(f"You don't have enough cash. Your current balance is ${balance:.2f}")
|
| 21 |
return
|
| 22 |
|
| 23 |
+
embed = discord.Embed(title="Dice Roll", description=f"{interaction.user.name} is betting ${bet:.2f}", color=0x787878)
|
| 24 |
embed.add_field(name="Current Balance", value=f"${balance:.2f}", inline=False)
|
| 25 |
|
| 26 |
roll_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll the Dice", custom_id="roll_dice")
|
|
|
|
| 44 |
embed.add_field(name="New Balance", value=f"${balance:.2f}", inline=False)
|
| 45 |
|
| 46 |
roll_again_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="Roll Again", custom_id="roll_again")
|
| 47 |
+
|
| 48 |
+
async def roll_again_callback(interaction: discord.Interaction):
|
| 49 |
+
await roll_dice(interaction, bet)
|
| 50 |
+
|
| 51 |
+
roll_again_button.callback = roll_again_callback
|
| 52 |
|
| 53 |
new_view = discord.ui.View()
|
| 54 |
new_view.add_item(roll_again_button)
|
|
|
|
| 60 |
view = discord.ui.View()
|
| 61 |
view.add_item(roll_button)
|
| 62 |
|
| 63 |
+
if interaction.response.is_done():
|
| 64 |
+
await interaction.followup.send(embed=embed, view=view)
|
| 65 |
+
else:
|
| 66 |
+
await interaction.response.send_message(embed=embed, view=view)
|