Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +7 -4
sportbet.py
CHANGED
@@ -75,6 +75,9 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
75 |
game_start = datetime.fromisoformat(self.game_data['startTime'].replace('Z', '+00:00'))
|
76 |
await asyncio.sleep((game_start - datetime.now(timezone.utc)).total_seconds())
|
77 |
|
|
|
|
|
|
|
78 |
previous_scores = {'away': 0, 'home': 0}
|
79 |
|
80 |
while True:
|
@@ -87,7 +90,7 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
87 |
for team in ['away', 'home']:
|
88 |
if current_scores[team] > previous_scores[team]:
|
89 |
team_name = game['teams'][team]['teamName']
|
90 |
-
await
|
91 |
|
92 |
previous_scores = current_scores.copy()
|
93 |
|
@@ -96,9 +99,9 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
96 |
if game['teams'][winner]['abbreviation'] == self.team:
|
97 |
winnings = bet_amount * 2
|
98 |
user_cash[self.user_id] += winnings
|
99 |
-
await
|
100 |
else:
|
101 |
-
await
|
102 |
|
103 |
user_bets[self.user_id] = [bet for bet in user_bets[self.user_id] if bet['game_data'] != self.game_data]
|
104 |
break
|
@@ -201,6 +204,6 @@ async def sportbet(interaction: discord.Interaction):
|
|
201 |
user_id = interaction.user.id
|
202 |
if user_id in user_bets and user_bets[user_id]:
|
203 |
view = SportBetView()
|
204 |
-
await interaction.response.send_message("?", view=view)
|
205 |
else:
|
206 |
await show_game_selection(interaction)
|
|
|
75 |
game_start = datetime.fromisoformat(self.game_data['startTime'].replace('Z', '+00:00'))
|
76 |
await asyncio.sleep((game_start - datetime.now(timezone.utc)).total_seconds())
|
77 |
|
78 |
+
user = await interaction.client.fetch_user(self.user_id)
|
79 |
+
await user.send(f"Your team {self.team} has started playing!")
|
80 |
+
|
81 |
previous_scores = {'away': 0, 'home': 0}
|
82 |
|
83 |
while True:
|
|
|
90 |
for team in ['away', 'home']:
|
91 |
if current_scores[team] > previous_scores[team]:
|
92 |
team_name = game['teams'][team]['teamName']
|
93 |
+
await user.send(f"{team_name} SCORED! Current score: {current_scores['away']} - {current_scores['home']}")
|
94 |
|
95 |
previous_scores = current_scores.copy()
|
96 |
|
|
|
99 |
if game['teams'][winner]['abbreviation'] == self.team:
|
100 |
winnings = bet_amount * 2
|
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 CRY")
|
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
|
|
|
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("What would you like to do?", view=view)
|
208 |
else:
|
209 |
await show_game_selection(interaction)
|