Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +9 -5
sportbet.py
CHANGED
@@ -46,7 +46,7 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
46 |
if bet_amount <= 0:
|
47 |
raise ValueError("Bet more than 0 dollars")
|
48 |
if bet_amount > user_cash.get(self.user_id, 0):
|
49 |
-
raise ValueError("
|
50 |
|
51 |
user_cash[self.user_id] -= bet_amount
|
52 |
await interaction.response.send_message(f"Bet placed on {self.team} for ${bet_amount}")
|
@@ -85,6 +85,10 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
85 |
game = next((g for g in scores['games'] if g['teams']['away']['abbreviation'] == self.game_data['teams']['away']['abbreviation'] and
|
86 |
g['teams']['home']['abbreviation'] == self.game_data['teams']['home']['abbreviation']), None)
|
87 |
|
|
|
|
|
|
|
|
|
88 |
current_scores = game['scores']
|
89 |
|
90 |
for team in ['away', 'home']:
|
@@ -101,7 +105,7 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
101 |
user_cash[self.user_id] += winnings
|
102 |
await user.send(f"Congratulations! Your team won. You won ${winnings}!")
|
103 |
else:
|
104 |
-
await user.send(f"Sorry, your team lost
|
105 |
|
106 |
user_bets[self.user_id] = [bet for bet in user_bets[self.user_id] if bet['game_data'] != self.game_data]
|
107 |
break
|
@@ -171,8 +175,8 @@ async def show_current_bets(interaction: discord.Interaction):
|
|
171 |
status = f"Starts <t:{int(start_time.timestamp())}:R>"
|
172 |
score = "N/A"
|
173 |
else:
|
174 |
-
status = game['status']['state']
|
175 |
-
score = f"{game['scores']['away']} - {game['scores']['home']}"
|
176 |
|
177 |
embed.add_field(name=f"Bet {i+1}", value=(
|
178 |
f"Team: {bet['team']}\n"
|
@@ -204,6 +208,6 @@ async def sportbet(interaction: discord.Interaction):
|
|
204 |
user_id = interaction.user.id
|
205 |
if user_id in user_bets and user_bets[user_id]:
|
206 |
view = SportBetView()
|
207 |
-
await interaction.response.send_message("?", view=view)
|
208 |
else:
|
209 |
await show_game_selection(interaction)
|
|
|
46 |
if bet_amount <= 0:
|
47 |
raise ValueError("Bet more than 0 dollars")
|
48 |
if bet_amount > user_cash.get(self.user_id, 0):
|
49 |
+
raise ValueError("You are too poor. Check your balance and try again")
|
50 |
|
51 |
user_cash[self.user_id] -= bet_amount
|
52 |
await interaction.response.send_message(f"Bet placed on {self.team} for ${bet_amount}")
|
|
|
85 |
game = next((g for g in scores['games'] if g['teams']['away']['abbreviation'] == self.game_data['teams']['away']['abbreviation'] and
|
86 |
g['teams']['home']['abbreviation'] == self.game_data['teams']['home']['abbreviation']), None)
|
87 |
|
88 |
+
if game is None:
|
89 |
+
await asyncio.sleep(60)
|
90 |
+
continue
|
91 |
+
|
92 |
current_scores = game['scores']
|
93 |
|
94 |
for team in ['away', 'home']:
|
|
|
105 |
user_cash[self.user_id] += winnings
|
106 |
await user.send(f"Congratulations! Your team won. You won ${winnings}!")
|
107 |
else:
|
108 |
+
await user.send(f"Sorry, your team lost. Better luck next time!")
|
109 |
|
110 |
user_bets[self.user_id] = [bet for bet in user_bets[self.user_id] if bet['game_data'] != self.game_data]
|
111 |
break
|
|
|
175 |
status = f"Starts <t:{int(start_time.timestamp())}:R>"
|
176 |
score = "N/A"
|
177 |
else:
|
178 |
+
status = game['status']['state'] if game else "Unknown"
|
179 |
+
score = f"{game['scores']['away']} - {game['scores']['home']}" if game else "Unknown"
|
180 |
|
181 |
embed.add_field(name=f"Bet {i+1}", value=(
|
182 |
f"Team: {bet['team']}\n"
|
|
|
208 |
user_id = interaction.user.id
|
209 |
if user_id in user_bets and user_bets[user_id]:
|
210 |
view = SportBetView()
|
211 |
+
await interaction.response.send_message("What would you like to do?", view=view)
|
212 |
else:
|
213 |
await show_game_selection(interaction)
|