Skip to content

Adding ComponentsV2 page (Popular Topics) #1620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

PakjeBecel
Copy link

  • Added new page under "Popular Topics" section called "Components V2"

Since I have an issue with running the guide in a local environment, I cannot run the guide locally. Someone else has to check first if this PR will render properly when merged.

@Amgelo563
Copy link
Contributor

I'm not sure whether we should call sections and text display "top level" components since they can also be used as a child inside a container, so it's half true, waiting for opinions.

@PakjeBecel
Copy link
Author

PakjeBecel commented May 4, 2025

@Amgelo563 Discord released the restrictions of top-level components, so maybe it isn't even worth mentioning whether a component is top-level or not anymore -- wrote those parts when the restriction still existed.

@Jiralite Jiralite added type: enhancement t: page/section addition Pull Request to add new content to the guide labels May 4, 2025
Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you place this file appropriately in guide/.vuepress/sidebar.ts? This will make it appear in the sidebar.

Looks like you have to run linting on your changes too.

@PakjeBecel PakjeBecel marked this pull request as ready for review May 4, 2025 22:55
Copy link
Member

@monbrey monbrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope I'm not coming across too harsh in my review - I really like the overall structure and the way the examples are presented.

My main concern is just the phrasing of CV2 as "new" and being a little overly comparative - they're only new now, but won't be forever. Write the guide as if they've always existed.

@@ -0,0 +1,228 @@
# Components V2

While you might be familiar with [embeds](/popular-topics/embeds.md) in Discord, there are now other ways to style your messages with new layout and content components. The interactive components ([buttons](/message-components/buttons.md) and [select menus](/message-components/select-menus.md)) have stayed the same, but it is now possible to change the position of those components in combination of the new layout components.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest avoiding point-in-time wording like "there are now other ways", "...have stayed the same". Yes, CV2 is currently new but it won't be new forever. Focus on highlighting what CV2 is, not it's differences to embeds or a previous state.

Maybe something like "Components V2 (CV2) provides comprehensive set of layout and content components to style your messages".


While you might be familiar with [embeds](/popular-topics/embeds.md) in Discord, there are now other ways to style your messages with new layout and content components. The interactive components ([buttons](/message-components/buttons.md) and [select menus](/message-components/select-menus.md)) have stayed the same, but it is now possible to change the position of those components in combination of the new layout components.

To use the new **Components V2 (CV2)** components, you need to pass in the new `IsComponentsV2` message flag from the <DocsLink path="MessageFlags:Enum" /> enum when sending a message. The flag should only be added to the message's `flags` field when the message contains CV2 components, unlike the `Ephemeral` message flag that can be added when you defer an interaction response.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To use the new **Components V2 (CV2)** components, you need to pass in the new `IsComponentsV2` message flag from the <DocsLink path="MessageFlags:Enum" /> enum when sending a message. The flag should only be added to the message's `flags` field when the message contains CV2 components, unlike the `Ephemeral` message flag that can be added when you defer an interaction response.
To use **Components V2 (CV2)**, you need to pass in the new `IsComponentsV2` message flag from the <DocsLink path="MessageFlags:Enum" /> enum when sending a message. The flag should only be added to the message's `flags` field when the message contains CV2 components, unlike the `Ephemeral` message flag that can be added when you defer an interaction response.

Same reasoning as my previous comment.

Once a message is sent or edited with the `IsComponentsV2` message flag, the flag **cannot** be removed from that message.
:::

All components, both new and existing, now have a new field `id` (which should not be confused with the existing `custom_id` field for interactive components), which is an optional 32-bit integer identifier for a component presented in a message. It is used to identify non-interactive components in the response from an interaction. More information about these can be found [here](https://discord.com/developers/docs/components/reference#anatomy-of-a-component).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
All components, both new and existing, now have a new field `id` (which should not be confused with the existing `custom_id` field for interactive components), which is an optional 32-bit integer identifier for a component presented in a message. It is used to identify non-interactive components in the response from an interaction. More information about these can be found [here](https://discord.com/developers/docs/components/reference#anatomy-of-a-component).
All components have an `id` field (which should not be confused with the `custom_id` field for interactive components), which is an optional 32-bit integer identifier for a component presented in a message. It is used to identify non-interactive components in the response from an interaction. More information about these can be found [here](https://discord.com/developers/docs/components/reference#anatomy-of-a-component).

Comment on lines +13 to +17
In the following section, we will explain what kind of components are new, how they work together with interactive components, and the limitations Discord has set when using CV2 components in your message.

## New components

CV2 brought new layout components and some new content components. The content components are very similar to some elements used in embeds, but their behaviour is slightly different when used relative to their use in embeds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the same here. Too much focus on "new" and too much comparison to embeds as a previous state.


### Text Display

A Text Display is a content component allowing you to add text to your message formatted with Discord's available markdown. This component is very similar to the `content` field of a message, but using multiple of these components you can control the layout of your message. You can use the <DocsLink path="TextDisplayBuilder:Class" /> utility class to easily create a Text Display component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A Text Display is a content component allowing you to add text to your message formatted with Discord's available markdown. This component is very similar to the `content` field of a message, but using multiple of these components you can control the layout of your message. You can use the <DocsLink path="TextDisplayBuilder:Class" /> utility class to easily create a Text Display component.
A Text Display is a content component for adding markdown-formatted text to your message. This component is very similar to the `content` field of a message, but by using multiple Text Display components, you gain greater control over the layout of your message. You can use the <DocsLink path="TextDisplayBuilder:Class" /> utility class to easily create a Text Display component.

Just a bit of a restructure on this paragraph, felt a little awkward to read for me personally. Curious how others feel.


### File

A File is a content component that can display any uploaded file as an attachment to a message and reference it in the File component itself. It can only display 1 attachment per File component, but using multiple File components, you can upload multiple files in one message. File components cannot have alt text (description), unlike a Thumbnail or Media Gallery component, but you can add a spoiler to the component. You can use the <DocsLink path="FileBuilder:Class" /> utility class to easily create a File component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A File is a content component that can display any uploaded file as an attachment to a message and reference it in the File component itself. It can only display 1 attachment per File component, but using multiple File components, you can upload multiple files in one message. File components cannot have alt text (description), unlike a Thumbnail or Media Gallery component, but you can add a spoiler to the component. You can use the <DocsLink path="FileBuilder:Class" /> utility class to easily create a File component.
A File is a content component that can display a single uploaded file attachment within the body of the message. By using multiple File components, you can upload and display multiple files in a single message. File components cannot have alt text (description), unlike a Thumbnail or Media Gallery component, but can be marked as a spoiler. You can use the <DocsLink path="FileBuilder:Class" /> utility class to easily create a File component.

Small restructure, and consistent wording around "marked as a spoiler".


### Separator

A Separator is a layout component that adds some vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to `true`). You can use the <DocsLink path="SeparatorBuilder:Class" /> utility class to easily create a Separator component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A Separator is a layout component that adds some vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to `true`). You can use the <DocsLink path="SeparatorBuilder:Class" /> utility class to easily create a Separator component.
A Separator is a layout component that adds vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to `true`). You can use the <DocsLink path="SeparatorBuilder:Class" /> utility class to easily create a Separator component.


### Section

A Section is a layout component allowing you to display text next to an accessory. You can use the <DocsLink path="SectionBuilder:Class" /> utility class to easily create a Section component. Every Section component must have at least 1 and at most 3 Text Display components with either a Thumbnail or Button component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A Section is a layout component allowing you to display text next to an accessory. You can use the <DocsLink path="SectionBuilder:Class" /> utility class to easily create a Section component. Every Section component must have at least 1 and at most 3 Text Display components with either a Thumbnail or Button component.
A Section is a layout component that places between one and three left-aligned Text Display components next to a right-aligned accessory (Thumbnail or Button component). At least one Text Display and the accessory are required. You can use the <DocsLink path="SectionBuilder:Class" /> utility class to easily create a Section component.


### Container

A Container is a layout component that will group its child components and has an optional color bar on the left, just like embeds. However, unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can also mark the Container component as a spoiler, to make all contents inside it blurred. You can use the <DocsLink path="ContainerBuilder:Class" /> utility class to easily create a Container component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A Container is a layout component that will group its child components and has an optional color bar on the left, just like embeds. However, unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can also mark the Container component as a spoiler, to make all contents inside it blurred. You can use the <DocsLink path="ContainerBuilder:Class" /> utility class to easily create a Container component.
A Container is a layout component which groups its child components inside a visually distinct rounded box with an optional accent color on the left, just like embeds. However, unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can also mark the Container component as a spoiler, which blurs all content inside the container. You can use the <DocsLink path="ContainerBuilder:Class" /> utility class to easily create a Container component.


A Container is a layout component that will group its child components and has an optional color bar on the left, just like embeds. However, unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can also mark the Container component as a spoiler, to make all contents inside it blurred. You can use the <DocsLink path="ContainerBuilder:Class" /> utility class to easily create a Container component.

The example below shows how to send a Container component in a channel containing a Text Display component, an Action Row component with a User Select component, two Separator components, and a Section component with two Text Display components where a Button component is present as an accessory.
Copy link
Member

@monbrey monbrey May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The example below shows how to send a Container component in a channel containing a Text Display component, an Action Row component with a User Select component, two Separator components, and a Section component with two Text Display components where a Button component is present as an accessory.
The example below shows how to send a Container component in a channel. It contains:
- a Text Display component
- an Action Row component with a User Select component
- two Separator components
- a Section component with two Text Display components and a Button component accessory

Might be easier to read as a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: page/section addition Pull Request to add new content to the guide type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants