#AttributeError: 'Button' object has no attribute 'response'

1 messages · Page 1 of 1 (latest)

median sapphire
#
    def __init__(self, user):
        super().__init__()
        self.user = user

    @discord.ui.button(label="Close", style=discord.ButtonStyle.red, emoji="❌")
    async def close_button(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.message.delete()

    @discord.ui.button(label="Add Link", style=discord.ButtonStyle.green, emoji="🔗")
    async def add_link_button(self, interaction: discord.Interaction, button: discord.ui.Button):
        # Send a message to the user to enter a link
        await interaction.response.send_message(content="Please send the link you want to add.", ephemeral=True)```

I looked over this code multiple times, but I just keep getting

await interaction.response.send_message(content="Please send the link you want to add.", ephemeral=True)
          ^^^^^^^^^^^^^^^^^^^^    
AttributeError: 'Button' object has no attribute 'response'
lost night
#

you need to put the button parameter before the interaction parameter

#

that's how it's passed to the button callback

modern rune
#

(button before interaction in the placement)

lost night
#

thanks for (wrongly) repeating what I just said

#

if they don't find that clear they can tell me themselves

languid socket