Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +13 -17
sportbet.py
CHANGED
@@ -120,16 +120,6 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
120 |
|
121 |
await asyncio.sleep(300)
|
122 |
|
123 |
-
class GameView(discord.ui.View):
|
124 |
-
def __init__(self, games):
|
125 |
-
super().__init__()
|
126 |
-
self.add_item(GameSelect(games))
|
127 |
-
|
128 |
-
class TeamView(discord.ui.View):
|
129 |
-
def __init__(self, away_team, home_team):
|
130 |
-
super().__init__()
|
131 |
-
self.add_item(TeamSelect(away_team, home_team))
|
132 |
-
|
133 |
@app_commands.command(name="sportbet", description="bet on sports game")
|
134 |
async def sportbet(interaction: discord.Interaction):
|
135 |
if interaction.user.id in user_bets and user_bets[interaction.user.id]:
|
@@ -146,22 +136,28 @@ async def sportbet(interaction: discord.Interaction):
|
|
146 |
await interaction.response.send_message("No games for betting.")
|
147 |
return
|
148 |
|
149 |
-
view =
|
|
|
|
|
|
|
150 |
await interaction.response.send_message("game to bet on:", view=view)
|
151 |
|
152 |
async def game_callback(interaction: discord.Interaction):
|
153 |
-
selected_game = next(game for game in upcoming_games if f"{game['teams']['away']['abbreviation']}_{game['teams']['home']['abbreviation']}" ==
|
154 |
|
155 |
-
team_view =
|
|
|
|
|
|
|
|
|
156 |
|
157 |
async def team_callback(interaction: discord.Interaction):
|
158 |
-
selected_team =
|
159 |
await interaction.response.send_modal(BetModal(selected_team, interaction.user.id, selected_game))
|
160 |
|
161 |
-
|
162 |
-
await interaction.response.edit_message(content="team to bet on:", view=team_view)
|
163 |
|
164 |
-
|
165 |
|
166 |
async def view_current_bets(interaction: discord.Interaction):
|
167 |
user_id = interaction.user.id
|
|
|
120 |
|
121 |
await asyncio.sleep(300)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
@app_commands.command(name="sportbet", description="bet on sports game")
|
124 |
async def sportbet(interaction: discord.Interaction):
|
125 |
if interaction.user.id in user_bets and user_bets[interaction.user.id]:
|
|
|
136 |
await interaction.response.send_message("No games for betting.")
|
137 |
return
|
138 |
|
139 |
+
view = discord.ui.View()
|
140 |
+
game_select = GameSelect(upcoming_games)
|
141 |
+
view.add_item(game_select)
|
142 |
+
|
143 |
await interaction.response.send_message("game to bet on:", view=view)
|
144 |
|
145 |
async def game_callback(interaction: discord.Interaction):
|
146 |
+
selected_game = next(game for game in upcoming_games if f"{game['teams']['away']['abbreviation']}_{game['teams']['home']['abbreviation']}" == game_select.values[0])
|
147 |
|
148 |
+
team_view = discord.ui.View()
|
149 |
+
team_select = TeamSelect(selected_game['teams']['away'], selected_game['teams']['home'])
|
150 |
+
team_view.add_item(team_select)
|
151 |
+
|
152 |
+
await interaction.response.edit_message(content="team to bet on:", view=team_view)
|
153 |
|
154 |
async def team_callback(interaction: discord.Interaction):
|
155 |
+
selected_team = team_select.values[0]
|
156 |
await interaction.response.send_modal(BetModal(selected_team, interaction.user.id, selected_game))
|
157 |
|
158 |
+
team_select.callback = team_callback
|
|
|
159 |
|
160 |
+
game_select.callback = game_callback
|
161 |
|
162 |
async def view_current_bets(interaction: discord.Interaction):
|
163 |
user_id = interaction.user.id
|