coollsd commited on
Commit
0c072aa
·
verified ·
1 Parent(s): cb91746

Update sportbet.py

Browse files
Files changed (1) hide show
  1. sportbet.py +13 -4
sportbet.py CHANGED
@@ -56,7 +56,7 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
56
  embed.add_field(name="Team", value=self.team, inline=False)
57
  embed.add_field(name="Amount", value=f"${bet_amount}", inline=False)
58
  embed.add_field(name="Game", value=f"{self.game_data['teams']['away']['teamName']} vs {self.game_data['teams']['home']['teamName']}", inline=False)
59
- embed.add_field(name="Start Time", value=f"<t:{int(datetime.fromisoformat(self.game_data['startTime'].replace('Z', '+00:00')).timestamp())}:R>", inline=False)
60
  await user.send(embed=embed)
61
 
62
  if self.user_id not in user_bets:
@@ -199,9 +199,18 @@ async def show_current_bets(interaction: discord.Interaction):
199
  return
200
 
201
  bet_index = int(cancel_select.values[0])
202
- cancelled_bet = user_bets[user_id].pop(bet_index)
 
 
 
 
 
 
 
 
203
  user_cash[user_id] += cancelled_bet['amount']
204
- await interaction.response.send_message(f"Bet cancelled. ${cancelled_bet['amount']} has been refunded")
 
205
 
206
  cancel_select.callback = cancel_callback
207
 
@@ -212,6 +221,6 @@ async def sportbet(interaction: discord.Interaction):
212
  user_id = interaction.user.id
213
  if user_id in user_bets and user_bets[user_id]:
214
  view = SportBetView()
215
- await interaction.response.send_message("?", view=view)
216
  else:
217
  await show_game_selection(interaction)
 
56
  embed.add_field(name="Team", value=self.team, inline=False)
57
  embed.add_field(name="Amount", value=f"${bet_amount}", inline=False)
58
  embed.add_field(name="Game", value=f"{self.game_data['teams']['away']['teamName']} vs {self.game_data['teams']['home']['teamName']}", inline=False)
59
+ embed.add_field(name="Start Time", value=f"<t:{int(datetime.fromisoformat(self.game_data['startTime'].replace('Z', '+00:00')).timestamp())}:F>", inline=False)
60
  await user.send(embed=embed)
61
 
62
  if self.user_id not in user_bets:
 
199
  return
200
 
201
  bet_index = int(cancel_select.values[0])
202
+ cancelled_bet = user_bets[user_id][bet_index]
203
+ game = cancelled_bet['game_data']
204
+ current_time = datetime.now(timezone.utc)
205
+ game_start = datetime.fromisoformat(game['startTime'].replace('Z', '+00:00'))
206
+
207
+ if current_time >= game_start:
208
+ await interaction.response.send_message("You cannot cancel your bet as the game has already started.", ephemeral=True)
209
+ return
210
+
211
  user_cash[user_id] += cancelled_bet['amount']
212
+ user_bets[user_id].pop(bet_index)
213
+ await interaction.response.send_message(f"Bet cancelled. ${cancelled_bet['amount']} has been refunded.")
214
 
215
  cancel_select.callback = cancel_callback
216
 
 
221
  user_id = interaction.user.id
222
  if user_id in user_bets and user_bets[user_id]:
223
  view = SportBetView()
224
+ await interaction.response.send_message("What would you like to do?", view=view)
225
  else:
226
  await show_game_selection(interaction)