Spaces:
Building
Building
Delete currentbets.py
Browse files- currentbets.py +0 -34
currentbets.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
import discord
|
2 |
-
from discord import app_commands
|
3 |
-
from shared import user_cash, user_bets, fetch_nhl_scores
|
4 |
-
|
5 |
-
@app_commands.command(name="currentbets", description="view your bets")
|
6 |
-
async def currentbets(interaction: discord.Interaction):
|
7 |
-
user_id = interaction.user.id
|
8 |
-
if user_id not in user_bets or not user_bets[user_id]:
|
9 |
-
await interaction.response.send_message("You have no bets.")
|
10 |
-
return
|
11 |
-
|
12 |
-
embed = discord.Embed(title="Your Current Bets", color=0x787878)
|
13 |
-
for i, bet in enumerate(user_bets[user_id]):
|
14 |
-
scores = await fetch_nhl_scores()
|
15 |
-
game = next((g for g in scores['games'] if g['teams']['away']['abbreviation'] == bet['game_data']['teams']['away']['abbreviation'] and
|
16 |
-
g['teams']['home']['abbreviation'] == bet['game_data']['teams']['home']['abbreviation']), None)
|
17 |
-
|
18 |
-
embed.add_field(name=f"Bet {i+1}", value=f"Team: {bet['team']}\nAmount: ${bet['amount']}\nGame: {bet['game_data']['teams']['away']['teamName']} vs {bet['game_data']['teams']['home']['teamName']}\nCurrent Score: {game['scores']['away']} - {game['scores']['home']}", inline=False)
|
19 |
-
|
20 |
-
view = discord.ui.View()
|
21 |
-
cancel_select = discord.ui.Select(placeholder="Select a bet to cancel", options=[
|
22 |
-
discord.SelectOption(label=f"Bet {i+1}", value=str(i)) for i in range(len(user_bets[user_id]))
|
23 |
-
])
|
24 |
-
view.add_item(cancel_select)
|
25 |
-
|
26 |
-
async def cancel_callback(interaction: discord.Interaction):
|
27 |
-
bet_index = int(cancel_select.values[0])
|
28 |
-
cancelled_bet = user_bets[user_id].pop(bet_index)
|
29 |
-
user_cash[user_id] += cancelled_bet['amount']
|
30 |
-
await interaction.response.send_message(f"Bet cancelled. ${cancelled_bet['amount']} has been refunded.")
|
31 |
-
|
32 |
-
cancel_select.callback = cancel_callback
|
33 |
-
|
34 |
-
await interaction.response.send_message(embed=embed, view=view)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|