Spaces:
Building
Building
Update sportbet.py
Browse files- sportbet.py +28 -5
sportbet.py
CHANGED
@@ -94,8 +94,19 @@ class BetModal(discord.ui.Modal, title="Place Your Bet"):
|
|
94 |
|
95 |
await asyncio.sleep(300)
|
96 |
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
scores = await fetch_nhl_scores()
|
100 |
upcoming_games = [game for game in scores['games'] if game['status']['state'] == 'PREVIEW']
|
101 |
|
@@ -126,8 +137,7 @@ async def sportbet(interaction: discord.Interaction):
|
|
126 |
|
127 |
game_select.callback = game_callback
|
128 |
|
129 |
-
|
130 |
-
async def currentbets(interaction: discord.Interaction):
|
131 |
user_id = interaction.user.id
|
132 |
if user_id not in user_bets or not user_bets[user_id]:
|
133 |
await interaction.response.send_message("You have no active bets.")
|
@@ -155,4 +165,17 @@ async def currentbets(interaction: discord.Interaction):
|
|
155 |
|
156 |
cancel_select.callback = cancel_callback
|
157 |
|
158 |
-
await interaction.response.send_message(embed=embed, view=view)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
await asyncio.sleep(300)
|
96 |
|
97 |
+
class SportBetView(discord.ui.View):
|
98 |
+
def __init__(self):
|
99 |
+
super().__init__()
|
100 |
+
|
101 |
+
@discord.ui.button(label="Bet Again", style=discord.ButtonStyle.primary)
|
102 |
+
async def bet_again(self, interaction: discord.Interaction, button: discord.ui.Button):
|
103 |
+
await show_game_selection(interaction)
|
104 |
+
|
105 |
+
@discord.ui.button(label="View Bets", style=discord.ButtonStyle.secondary)
|
106 |
+
async def view_bets(self, interaction: discord.Interaction, button: discord.ui.Button):
|
107 |
+
await show_current_bets(interaction)
|
108 |
+
|
109 |
+
async def show_game_selection(interaction: discord.Interaction):
|
110 |
scores = await fetch_nhl_scores()
|
111 |
upcoming_games = [game for game in scores['games'] if game['status']['state'] == 'PREVIEW']
|
112 |
|
|
|
137 |
|
138 |
game_select.callback = game_callback
|
139 |
|
140 |
+
async def show_current_bets(interaction: discord.Interaction):
|
|
|
141 |
user_id = interaction.user.id
|
142 |
if user_id not in user_bets or not user_bets[user_id]:
|
143 |
await interaction.response.send_message("You have no active bets.")
|
|
|
165 |
|
166 |
cancel_select.callback = cancel_callback
|
167 |
|
168 |
+
await interaction.response.send_message(embed=embed, view=view)
|
169 |
+
|
170 |
+
@app_commands.command(name="sportbet", description="Bet on sports games")
|
171 |
+
async def sportbet(interaction: discord.Interaction):
|
172 |
+
user_id = interaction.user.id
|
173 |
+
if user_id in user_bets and user_bets[user_id]:
|
174 |
+
view = SportBetView()
|
175 |
+
await interaction.response.send_message("What would you like to do?", view=view)
|
176 |
+
else:
|
177 |
+
await show_game_selection(interaction)
|
178 |
+
|
179 |
+
@app_commands.command(name="currentbets", description="View your current bets")
|
180 |
+
async def currentbets(interaction: discord.Interaction):
|
181 |
+
await show_current_bets(interaction)
|