coollsd commited on
Commit
d478ceb
·
verified ·
1 Parent(s): 4b787ce

Update sportbet.py

Browse files
Files changed (1) hide show
  1. sportbet.py +5 -2
sportbet.py CHANGED
@@ -150,6 +150,8 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
150
 
151
  if self.user_id not in user_bets:
152
  user_bets[self.user_id] = []
 
 
153
  user_bets[self.user_id].append({
154
  "league": self.league,
155
  "team": self.team,
@@ -199,7 +201,8 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
199
  current_score=current_scores[key]
200
  previous_score=previous_scores[key]
201
 
202
- if previous_score is None or current_score!=previous_score:
 
203
  score_changed=True
204
 
205
  previous_scores=current_scores.copy()
@@ -207,7 +210,7 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
207
  if score_changed:
208
  away_score=current_scores["away"] or 'N/A'
209
  home_score=current_scores["home"] or 'N/A'
210
- message=f"Current score update: {away_score} - {home_score}"
211
  user=await interaction.client.fetch_user(self.user_id)
212
  await user.send(message)
213
 
 
150
 
151
  if self.user_id not in user_bets:
152
  user_bets[self.user_id] = []
153
+
154
+ # Initialize previous scores to None to track changes only when they occur.
155
  user_bets[self.user_id].append({
156
  "league": self.league,
157
  "team": self.team,
 
201
  current_score=current_scores[key]
202
  previous_score=previous_scores[key]
203
 
204
+ # Only notify when the score changes from a non-None state.
205
+ if previous_score is not None and current_score!=previous_score:
206
  score_changed=True
207
 
208
  previous_scores=current_scores.copy()
 
210
  if score_changed:
211
  away_score=current_scores["away"] or 'N/A'
212
  home_score=current_scores["home"] or 'N/A'
213
+ message=f"Score update: {away_score} - {home_score}"
214
  user=await interaction.client.fetch_user(self.user_id)
215
  await user.send(message)
216