Skip to content

Pycord button view #1938

Closed Answered by JustaSqu1d
BatteTarte asked this question in Q&A
Feb 23, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can pass in the arguments into the view constructor and create the button by object:

class MyView(discord.ui.View):
    def __init__(self, label: str):
        super().__init__()
        button = discord.ui.Button(label = label,
        ...)
       
    async def button_callback(self, interaction):
            ...

@bot.slash_command()
async def test(ctx, word:str):
    await ctx.respond("Take the view",view=MyView(word))

I would like to add that this discussion category should not be used for help, rather, please join our Discord server for help instead. If you require further assistance please do the same.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lulalaby
Comment options

Answer selected by BatteTarte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants