Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +8 -8
sportbet.py
CHANGED
@@ -78,29 +78,29 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
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:
|
84 |
scores = await fetch_nhl_scores()
|
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']:
|
95 |
if current_scores[team] > previous_scores[team]:
|
96 |
-
team_name = game['teams'][team]['teamName']
|
97 |
-
await user.send(f"{team_name} SCORED! Current score: {current_scores['away']} - {current_scores['home']}")
|
98 |
|
99 |
previous_scores = current_scores.copy()
|
100 |
|
101 |
if game['status']['state'] == 'FINAL':
|
102 |
-
winner = 'away' if
|
103 |
-
if
|
104 |
winnings = bet_amount * 2
|
105 |
user_cash[self.user_id] += winnings
|
106 |
await user.send(f"Congratulations! Your team won. You won ${winnings}!")
|
@@ -176,7 +176,7 @@ async def show_current_bets(interaction: discord.Interaction):
|
|
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"
|
|
|
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 = {self.game_data['teams']['away']['abbreviation']: 0, self.game_data['teams']['home']['abbreviation']: 0}
|
82 |
|
83 |
while True:
|
84 |
scores = await fetch_nhl_scores()
|
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 or game['status']['state'] == 'PREVIEW':
|
89 |
await asyncio.sleep(60)
|
90 |
continue
|
91 |
|
92 |
current_scores = game['scores']
|
93 |
|
94 |
+
for team in [self.game_data['teams']['away']['abbreviation'], self.game_data['teams']['home']['abbreviation']]:
|
95 |
if current_scores[team] > previous_scores[team]:
|
96 |
+
team_name = game['teams']['away']['teamName'] if team == game['teams']['away']['abbreviation'] else game['teams']['home']['teamName']
|
97 |
+
await user.send(f"{team_name} SCORED! Current score: {current_scores[self.game_data['teams']['away']['abbreviation']]} - {current_scores[self.game_data['teams']['home']['abbreviation']]}")
|
98 |
|
99 |
previous_scores = current_scores.copy()
|
100 |
|
101 |
if game['status']['state'] == 'FINAL':
|
102 |
+
winner = self.game_data['teams']['away']['abbreviation'] if current_scores[self.game_data['teams']['away']['abbreviation']] > current_scores[self.game_data['teams']['home']['abbreviation']] else self.game_data['teams']['home']['abbreviation']
|
103 |
+
if winner == self.team:
|
104 |
winnings = bet_amount * 2
|
105 |
user_cash[self.user_id] += winnings
|
106 |
await user.send(f"Congratulations! Your team won. You won ${winnings}!")
|
|
|
176 |
score = "N/A"
|
177 |
else:
|
178 |
status = game['status']['state'] if game else "Unknown"
|
179 |
+
score = f"{game['scores'][bet['game_data']['teams']['away']['abbreviation']]} - {game['scores'][bet['game_data']['teams']['home']['abbreviation']]}" if game and 'scores' in game else "Unknown"
|
180 |
|
181 |
embed.add_field(name=f"Bet {i+1}", value=(
|
182 |
f"Team: {bet['team']}\n"
|