2023-06-19 14:20:17 +00:00
|
|
|
import discord
|
|
|
|
from discord.ui import View
|
|
|
|
|
|
|
|
|
|
|
|
class BlackJackButtons(View):
|
|
|
|
def __init__(self, ctx):
|
|
|
|
super().__init__(timeout=180)
|
|
|
|
self.ctx = ctx
|
|
|
|
self.clickedHit = False
|
|
|
|
self.clickedStand = False
|
|
|
|
self.clickedDoubleDown = False
|
|
|
|
|
|
|
|
async def on_timeout(self):
|
|
|
|
for child in self.children:
|
|
|
|
child.disabled = True
|
|
|
|
await self.message.edit(view=None)
|
|
|
|
|
2024-07-08 17:22:17 +00:00
|
|
|
@discord.ui.button(
|
2024-07-17 11:47:26 +00:00
|
|
|
label="hit",
|
|
|
|
style=discord.ButtonStyle.gray,
|
|
|
|
emoji="<:hit:1119262723285467156> ",
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2023-06-19 14:20:17 +00:00
|
|
|
async def hit_button_callback(self, button, interaction):
|
|
|
|
self.clickedHit = True
|
|
|
|
await interaction.response.defer()
|
|
|
|
self.stop()
|
|
|
|
|
2024-07-08 17:22:17 +00:00
|
|
|
@discord.ui.button(
|
|
|
|
label="stand",
|
|
|
|
style=discord.ButtonStyle.gray,
|
|
|
|
emoji="<:stand:1118923298298929154>",
|
|
|
|
)
|
2023-06-19 14:20:17 +00:00
|
|
|
async def stand_button_callback(self, button, interaction):
|
|
|
|
self.clickedStand = True
|
|
|
|
await interaction.response.defer()
|
|
|
|
self.stop()
|
|
|
|
|
|
|
|
async def interaction_check(self, interaction) -> bool:
|
2024-07-19 21:26:49 +00:00
|
|
|
if interaction.user == self.ctx.author:
|
2023-06-19 14:20:17 +00:00
|
|
|
return True
|
2024-07-19 21:26:49 +00:00
|
|
|
await interaction.response.send_message(
|
|
|
|
"You can't use these buttons, they're someone else's!",
|
|
|
|
ephemeral=True,
|
|
|
|
)
|
|
|
|
return False
|
2023-06-19 14:20:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ExchangeConfirmation(View):
|
|
|
|
def __init__(self, ctx):
|
|
|
|
super().__init__(timeout=180)
|
|
|
|
self.ctx = ctx
|
|
|
|
self.clickedConfirm = False
|
|
|
|
|
|
|
|
async def on_timeout(self):
|
|
|
|
for child in self.children:
|
|
|
|
child.disabled = True
|
|
|
|
await self.message.edit(view=None)
|
|
|
|
|
|
|
|
@discord.ui.button(label="Confirm", style=discord.ButtonStyle.green)
|
|
|
|
async def confirm_button_callback(self, button, interaction):
|
|
|
|
await interaction.response.edit_message(view=None)
|
|
|
|
self.clickedConfirm = True
|
|
|
|
self.stop()
|
|
|
|
|
|
|
|
@discord.ui.button(label="Stop", style=discord.ButtonStyle.red)
|
|
|
|
async def stop_button_callback(self, button, interaction):
|
|
|
|
await interaction.response.edit_message(view=None)
|
|
|
|
self.stop()
|
|
|
|
|
|
|
|
async def interaction_check(self, interaction) -> bool:
|
2024-07-19 21:26:49 +00:00
|
|
|
if interaction.user == self.ctx.author:
|
2023-06-19 14:20:17 +00:00
|
|
|
return True
|
2024-07-19 21:26:49 +00:00
|
|
|
await interaction.response.send_message(
|
|
|
|
"You can't use these buttons, they're someone else's!",
|
|
|
|
ephemeral=True,
|
|
|
|
)
|
|
|
|
return False
|