#New buttons and dropdowns with components v2

1 messages · Page 1 of 1 (latest)

frozen spear
#

Hello, I'm trying to learn discord components v2 in pycord but I don't know how to put buttons in the cointainer next to a text or other.
I try to make a container (on the first pic)
Here my code :

from io import BytesIO

from discord import (
    ApplicationContext,
    Bot,
    SeparatorSpacingSize,
    User,
)
from discord.ui import (
    Container,
    Separator,
    TextDisplay,
    View,
)


class MyView(View):
    def __init__(self):
        super().__init__(timeout=None)
        text1 = TextDisplay("## Welcome to 7 Exchange.")
        text2 = TextDisplay(
            "7 Exchange offers a secure and trusted platform for converting your fiat currency into cryptocurrency—ensuring competitive rates and top-tier security every step of the way."
        )
        text3 = TextDisplay("Before getting started, please take a moment to review our Terms of Service and Fee rates.")


        container = Container(
            text1,text2,text3,
            color=0x1567E1,
        )
        container.add_item(Separator(spacing=SeparatorSpacingSize.small))
        container.add_text("- Ready to begin your exchange? Simply click the button below to open a support ticket.")
        container.add_text("- Our system is designed as a secure intermediary—our dedicated team oversees every transaction to ensure a seamless and reliable experience.")


        self.add_item(container)




bot = Bot()


@bot.command()
async def show_view(ctx: ApplicationContext):
    """Display a sample View showcasing various new components."""

    await ctx.respond(view=MyView())


bot.run("----------------")
#

Container i'm trying to make :

#

Container with my code :

#

Pls, i want to know how to put buttons at the right of texts and how tu put a big banner like that

radiant fjord
#

Those are Sections

#

You need to create one, container is the "embed"

indigo sparrow
#

Sections with a button as the accessory. The banner is a media gallery with one media component.

frozen spear
# indigo sparrow Sections with a button as the accessory. The banner is a media gallery with one ...

ok but how can I set the position of the button

        text1 = TextDisplay("## Welcome to 7 Exchange.")
        text2 = TextDisplay(
            "7 Exchange offers a secure and trusted platform for converting your fiat currency into cryptocurrency—ensuring competitive rates and top-tier security every step of the way."
        )
        text3 = TextDisplay("Before getting started, please take a moment to review our Terms of Service and Fee rates.")
        btn = Button(label="View TOS", emoji="🌐", url="https://discord.com/login")
        section =  Section(text1, text2, text3, accessory=btn)

        container = Container(
            section,
            color=0x1567E1,
        )
indigo sparrow
#

They probably have text1 and 2 before the section. Only text3 is in the section