Merge branch 'BlackJackIntegration'
This commit is contained in:
@@ -20,6 +20,29 @@ async def test(interaction:discord.Interaction):
|
|||||||
except discord.app_commands.errors.CommandInvokeError:
|
except discord.app_commands.errors.CommandInvokeError:
|
||||||
print("Uh oh! It failed!")
|
print("Uh oh! It failed!")
|
||||||
|
|
||||||
|
class HitOrStand(discord.ui.View):
|
||||||
|
def __init__(self, *, timeout=180):
|
||||||
|
super().__init__(timeout=timeout)
|
||||||
|
self.content = None
|
||||||
|
|
||||||
|
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
|
||||||
|
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
self.content = "h"
|
||||||
|
for child in self.children:
|
||||||
|
child.disabled = True
|
||||||
|
await interaction.response.edit_message(content="You Hit!", view=self)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
|
@discord.ui.button(label="Stand", style=discord.ButtonStyle.red)
|
||||||
|
async def stand(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
self.content = "s"
|
||||||
|
for child in self.children:
|
||||||
|
child.disabled = True
|
||||||
|
await interaction.response.edit_message(content="You stood!", view=self)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Buttons(discord.ui.View):
|
class Buttons(discord.ui.View):
|
||||||
def __init__(self, *, timeout=180):
|
def __init__(self, *, timeout=180):
|
||||||
super().__init__(timeout=timeout)
|
super().__init__(timeout=timeout)
|
||||||
@@ -51,11 +74,10 @@ async def bj(interaction: discord.Interaction):
|
|||||||
await blackJack.play_game(100)
|
await blackJack.play_game(100)
|
||||||
|
|
||||||
async def discordInput(interaction: discord.Interaction, message:str):
|
async def discordInput(interaction: discord.Interaction, message:str):
|
||||||
await interaction.followup.send(message)
|
response = HitOrStand()
|
||||||
def check(m):
|
await interaction.followup.send(message, view=response)
|
||||||
return m.content in ["h", "s"] and m.channel == interaction.channel
|
await response.wait()
|
||||||
msg = await client.wait_for('message', check=check)
|
return response.content
|
||||||
return msg.content
|
|
||||||
|
|
||||||
async def discordOutput(interaction: discord.Interaction, message):
|
async def discordOutput(interaction: discord.Interaction, message):
|
||||||
await interaction.followup.send(message)
|
await interaction.followup.send(message)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user