Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +22 -8
sportbet.py
CHANGED
@@ -144,12 +144,30 @@ async def show_current_bets(interaction: discord.Interaction):
|
|
144 |
return
|
145 |
|
146 |
embed = discord.Embed(title="Your Current Bets", color=0x787878)
|
|
|
|
|
147 |
for i, bet in enumerate(user_bets[user_id]):
|
148 |
-
scores = await fetch_nhl_scores()
|
149 |
game = next((g for g in scores['games'] if g['teams']['away']['abbreviation'] == bet['game_data']['teams']['away']['abbreviation'] and
|
150 |
g['teams']['home']['abbreviation'] == bet['game_data']['teams']['home']['abbreviation']), None)
|
151 |
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
view = discord.ui.View()
|
155 |
cancel_select = discord.ui.Select(placeholder="Select a bet to cancel", options=[
|
@@ -172,10 +190,6 @@ async def sportbet(interaction: discord.Interaction):
|
|
172 |
user_id = interaction.user.id
|
173 |
if user_id in user_bets and user_bets[user_id]:
|
174 |
view = SportBetView()
|
175 |
-
await interaction.response.send_message("
|
176 |
else:
|
177 |
-
await show_game_selection(interaction)
|
178 |
-
|
179 |
-
@app_commands.command(name="currentbets", description="View your current bets")
|
180 |
-
async def currentbets(interaction: discord.Interaction):
|
181 |
-
await show_current_bets(interaction)
|
|
|
144 |
return
|
145 |
|
146 |
embed = discord.Embed(title="Your Current Bets", color=0x787878)
|
147 |
+
scores = await fetch_nhl_scores()
|
148 |
+
|
149 |
for i, bet in enumerate(user_bets[user_id]):
|
|
|
150 |
game = next((g for g in scores['games'] if g['teams']['away']['abbreviation'] == bet['game_data']['teams']['away']['abbreviation'] and
|
151 |
g['teams']['home']['abbreviation'] == bet['game_data']['teams']['home']['abbreviation']), None)
|
152 |
|
153 |
+
start_time = datetime.fromisoformat(bet['game_data']['startTime'].replace('Z', '+00:00'))
|
154 |
+
current_time = datetime.now(timezone.utc)
|
155 |
+
|
156 |
+
if current_time < start_time:
|
157 |
+
status = f"Starts <t:{int(start_time.timestamp())}:R>"
|
158 |
+
score = "N/A"
|
159 |
+
else:
|
160 |
+
status = game['status']['state']
|
161 |
+
score = f"{game['scores']['away']} - {game['scores']['home']}"
|
162 |
+
|
163 |
+
embed.add_field(name=f"Bet {i+1}", value=(
|
164 |
+
f"Team: {bet['team']}\n"
|
165 |
+
f"Amount: ${bet['amount']}\n"
|
166 |
+
f"Game: {bet['game_data']['teams']['away']['teamName']} vs {bet['game_data']['teams']['home']['teamName']}\n"
|
167 |
+
f"Status: {status}\n"
|
168 |
+
f"Current Score: {score}\n"
|
169 |
+
f"Start Time: <t:{int(start_time.timestamp())}:F>"
|
170 |
+
), inline=False)
|
171 |
|
172 |
view = discord.ui.View()
|
173 |
cancel_select = discord.ui.Select(placeholder="Select a bet to cancel", options=[
|
|
|
190 |
user_id = interaction.user.id
|
191 |
if user_id in user_bets and user_bets[user_id]:
|
192 |
view = SportBetView()
|
193 |
+
await interaction.response.send_message("?", view=view)
|
194 |
else:
|
195 |
+
await show_game_selection(interaction)
|
|
|
|
|
|
|
|