#Link Button

1 messages · Page 1 of 1 (latest)

viscid oar
#

Can you show what you see in discord?

hollow hinge
#

I don't believe url buttons have a callback

#

you can't use them that way I think, since it's a link

#

Could you show the code where you send the button in the message?

crystal atlasBOT
#

Here's the link example.

viscid oar
#

yea true

#

also, link buttons cant be made with the decorator

#

"Verificate" lol

#

(verify / verified btw)

crystal atlasBOT
#

Here's the link example.

inland yew
#

Mb

viscid oar
#

i already sent that

inland yew
#

Chat wasnt loaded completely

#

Also link button has no callback

hollow hinge
#
class MyView(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(discord.ui.Button(label="Website", url="https://www.google.at/"))

    @discord.ui.button(label="Verify", style=discord.ButtonStyle.success, emoji="✅")
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("You got verificated!")

viscid oar
#

was also already said

inland yew
viscid oar
#

#1239200733329490031 message

viscid oar
inland yew
#

Are you going to check every single of my message ?

hollow hinge
viscid oar
#

we dont need 500 people in one post

inland yew
hollow hinge
#

@gleaming temple
Url buttons don't have a callback, in short you can't know when they are pressed directly from discord. This is why your code was crashing. You can create url buttons in the view's initialization (__init__) which is ran every time the view is created. Here is what your code should look like

class MyView(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(discord.ui.Button(label="Website", url="https://www.google.at/")) # Link button

    @discord.ui.button(label="Verify", style=discord.ButtonStyle.success, emoji="✅")
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("You got verificated!")