Buttons work

This commit is contained in:
2022-11-23 21:36:58 +10:00
parent ac58d1e126
commit c04f2f1f13

View File

@@ -28,10 +28,20 @@ class HitOrStand(discord.ui.View):
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green) @discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button): async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
self.content = "h" 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) @discord.ui.button(label="Stand", style=discord.ButtonStyle.red)
async def stand(self, interaction: discord.Interaction, button: discord.ui.Button): async def stand(self, interaction: discord.Interaction, button: discord.ui.Button):
self.content = "s" 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):
@@ -66,7 +76,7 @@ async def bj(interaction: discord.Interaction):
async def discordInput(interaction: discord.Interaction, message:str): async def discordInput(interaction: discord.Interaction, message:str):
response = HitOrStand() response = HitOrStand()
await interaction.followup.send(message, view=response) await interaction.followup.send(message, view=response)
print(response.content) await response.wait()
return response.content return response.content
async def discordOutput(interaction: discord.Interaction, message): async def discordOutput(interaction: discord.Interaction, message):