Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 448

Python: Discord Button Rows with different amount of buttons

$
0
0

So I am currently trying to make an archive bot where you can select characters and get all the information about them. I used buttons for each character.

Now I would want to sort the button rows so that each house/attribute has their own row. There are different amounts of characters in each house. Min 2 and max 4.

How can I sort the rows so it'll only show character buttons of one house for each row? For now it will always use 5 for each row.Thanks!

Thats my code so far:

async def archive(ctx):characters = {"Name": {"dropdown": NameDropdown, "image": "", "emoji": ""},    ...}embed = discord.Embed(    title="",    description="",    color=COLOR)view = discord.ui.View(timeout=None)for char_name, char_data in characters.items():    button = discord.ui.Button(        label=char_name,        style=discord.ButtonStyle.secondary,        emoji=char_data["emoji"],        custom_id=f"character_{char_name}"    )    async def button_callback(interaction: discord.Interaction, char_name=char_name, char_data=char_data):        char_dropdown = char_data["dropdown"]()        embed = discord.Embed(            title=f"{char_name}",            description=f"",            color=COLOR        )        embed.set_image(url=char_data["image"])         await interaction.response.send_message(embed=embed, view=char_dropdown, ephemeral=True)    button.callback = button_callback    view.add_item(button)await ctx.send(embed=embed, view=view)await ctx.message.delete()

I tried working with discord.ui.ActionRow() but it seems I'm not able to understand how to use it properly or my information is outdated. Error codes like:

"AttributeError: module 'discord.ui' has no attribute 'ActionRow'"

were the result.


Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>