From ac58d1e126cf3f7d0534bba021f1dc8e73f2e837 Mon Sep 17 00:00:00 2001 From: BigGamerGary Date: Wed, 23 Nov 2022 21:28:03 +1000 Subject: [PATCH] Buttons send, don't work --- Acronymbot.py | 22 +++++++++++++++++----- __pycache__/BlackJack.cpython-310.pyc | Bin 6759 -> 6332 bytes 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Acronymbot.py b/Acronymbot.py index 1caa3ca..9068186 100644 --- a/Acronymbot.py +++ b/Acronymbot.py @@ -20,6 +20,19 @@ async def test(interaction:discord.Interaction): except discord.app_commands.errors.CommandInvokeError: 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" + + @discord.ui.button(label="Stand", style=discord.ButtonStyle.red) + async def stand(self, interaction: discord.Interaction, button: discord.ui.Button): + self.content = "s" + class Buttons(discord.ui.View): def __init__(self, *, timeout=180): super().__init__(timeout=timeout) @@ -51,11 +64,10 @@ async def bj(interaction: discord.Interaction): await blackJack.play_game(100) async def discordInput(interaction: discord.Interaction, message:str): - await interaction.followup.send(message) - def check(m): - return m.content in ["h", "s"] and m.channel == interaction.channel - msg = await client.wait_for('message', check=check) - return msg.content + response = HitOrStand() + await interaction.followup.send(message, view=response) + print(response.content) + return response.content async def discordOutput(interaction: discord.Interaction, message): await interaction.followup.send(message) diff --git a/__pycache__/BlackJack.cpython-310.pyc b/__pycache__/BlackJack.cpython-310.pyc index 85398a4291f34c1a1469ba9a86d290b194368ca1..fbb709fdb15eea1e6f234d21d5d3f8015503eee8 100644 GIT binary patch delta 75 zcmaEEvd54wpO=@50SF%buT4HFKao#{(QBf%7b{~hgQmd7DG$Y&G&v@Jkfb54ivU delta 500 zcmZ`$u}%U(5Zzh88%{w%BSekbo+bvPC84oV6D_18G32;C739F|K|>&D;0FkmotBoy z*xC6P*ID@ilomPzAu%RS^4`AL*?BX`zU_YQ$Lq0}DJWjQI?l`HAif4_uzkF-pb~vi zKsTzA*HUL(>I79L zlq3~kwrYDNW#{I|Y{X_LTFahYuI*&2b;qvyITDj6|IXGIY&w~#&sbkEB}Di4EM1|? z7>&`_T(yZTskd04unrZX4Oe^PjSD8rdb2^>2eMT8yLOm2oFy-xe@5OSAegWO+M_hU wVv*~`qO{E6dD@!cTkQ-J>D2H(J-@y}DGChXDn>Da1{(3W=;8qyCWOC#02lpVT>t<8