#Dynamic Buttons/Select Menus
1 messages · Page 1 of 1 (latest)
view.add_item(button)
So would this work?
view = viewbut()
for v in listobj:
view.add_item(v)
(With v being implemented into a button object I used just v for simplicity)
@long lynx
.tias
It worked! However, how do I check when it's called? The typical arragement is this:
...
class View(discord.ui.View):
def __init__(self):
#self.bot = bot
super().__init__(timeout=None)
@discord.ui.button(label="test", style=discord.ButtonStyle.green, custom_id="testbut1")
async def reactbutton(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(button.label)
...
@discord.slash_command(name="button",description="test") # we can also add application commands
async def button(self, ctx):
view = View()
view.add_item(discord.ui.Button(label="test1", style=discord.ButtonStyle.green, custom_id="testbut2"))
await ctx.respond("Test", view=view)
...
I can't activate the view components without called ui.button and I don't know how to check if the ui itself is called
Nevermind I found my answer here: https://github.com/Pycord-Development/pycord/blob/master/examples/views/button_roles.py
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - Pycord-Development/pycord