#๐Ÿ”’ discord.py button issue

49 messages ยท Page 1 of 1 (latest)

edgy jacinth
#
async def handle_cashapp_deposit(interaction: discord.Interaction, amount: float):
    cashapp_info = load_json(CASHAPP_INFO_FILE)
    user_id = str(interaction.user.id)
    
    if user_id in cashapp_info and cashapp_info[user_id].get('status') not in ['finished', 'confirmed', 'done', 'failed', 'refunded', 'expired', 'cancelled']:
        await interaction.response.send_message("โš ๏ธ You already have an ongoing transaction.", ephemeral=True)
        return

    note = generate_unique_note()
    cashtag = "$ephishing"

    cashapp_info[user_id] = {
        'amount': amount,
        'note': note,
        'status': 'pending'
    }
    save_json(CASHAPP_INFO_FILE, cashapp_info)

    embed = Embed(
        title="CashApp Deposit",
        description=f"**Amount:** {amount}\n**Cashtag:** {cashtag}\n**Note:** {note}",
        color=discord.Color.blue()
    )
    embed.set_author(name=interaction.user.name, icon_url=interaction.user.avatar.url)
    
    view = CashAppView(user_id)

    await interaction.response.send_message(
        embed=embed,
        ephemeral=True,
        view=view
    )

class CashAppView(View):
    def __init__(self, user_id: str):
        super().__init__()
        self.user_id = user_id

    @discord.ui.button(label="Check CashApp Payment", style=ButtonStyle.primary)
    async def check_payment(self, ask_for_receipt_url, interaction):
        await ask_for_receipt_url(interaction)

async def ask_for_receipt_url(interaction: discord.Interaction):
    await interaction.response.send_message("Please provide the web receipt URL for your CashApp payment:", ephemeral=True)

    def check(msg):
        return msg.author == interaction.user and isinstance(msg.channel, discord.TextChannel)

    try:
        msg = await interaction.client.wait_for('message', check=check, timeout=300)
        await handle_receipt_url(msg)
    except asyncio.TimeoutError:
        await interaction.response.send_message("โฐ You took too long to respond. Please try again.", ephemeral=True)


async def handle_receipt_url(message: discord.Message):
    cashapp_info = load_json(CASHAPP_INFO_FILE)
    user_id = str(message.author.id)
    receipt_url = message.content.strip()

error when I click the button it shows "this interaction failed", in the picture it shows the error code, it sends the embed perfect just button error

south crowBOT
#

@edgy jacinth

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lone stag
edgy jacinth
#

nope

#

just like a payment acceptor>

#

unless it is?

#

if it is u can js delete the ticket

#

its for like a payment viewer

lone stag
# edgy jacinth unless it is?

well for a start you cannot allow minors to use cashapp, and discord's userbase is 13+ so that could cause some issues

#

wait nevermind

#

13+ for cashapp too

edgy jacinth
#

13+ ca

#

atleast in america

#

adding a thing before

#

so u agree to cashapp n discord tos

#

n are 13+

lone stag
lone stag
#

oh wait its here ```py
async def check_payment(self, ask_for_receipt_url, interaction):

#

what exactly is this supposed to be

edgy jacinth
#

trying to have it call that function

lone stag
edgy jacinth
lone stag
#

in dpy your buttons are structured like this: ```py
@button(button_contents)
async def button_callback(self, interaction: Interaction, button: Button):
... # the code to run after clicking the button

lone stag
edgy jacinth
#

i had this before

lone stag
#

thats your problem

edgy jacinth
#
    @discord.ui.button(label="Check CashApp Payment", style=ButtonStyle.primary)
    async def check_payment(self, button: Button, interaction: Interaction):
        await ask_for_receipt_url(interaction)

edgy jacinth
#

yeah i see

carmine lotus
edgy jacinth
#
    @button(label="Check CashApp Payment", style=ButtonStyle.primary)
    async def check_payment(self, interaction: Interaction, button: Button):
        await ask_for_receipt_url(interaction)
#

Im pretty sure i got it 1 second

#

all good problem solved

#

@carmine lotus @lone stag ty

lone stag
edgy jacinth
#

?close

bold nacelleBOT
#

This is not a Modmail thread.

edgy jacinth
#

@lone stag

#

?close

bold nacelleBOT
#

This is not a Modmail thread.

lone stag
#

oh wait

#

@edgy jacinth !close

edgy jacinth
#

!close

south crowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.