You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/reference/templates/functions.md
+98Lines changed: 98 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -779,6 +779,104 @@ object](/docs/reference/templates/syntax-and-data#message). Is also valid for ep
779
779
780
780
---
781
781
782
+
## Component V2
783
+
784
+
Components V2 introduces a new way to create interactive and visually appealing message layouts in Discord applications, allowing for greater control over message formatting and user interaction.
785
+
786
+
### componentBuilder
787
+
788
+
`componentBuilder` is a helper for building Discord's new Components V2 (sections, buttons, menus, galleries, etc.) in YAGPDB custom commands.
Returns a complex message object with the given components.
794
+
795
+
All keys are optional, but the Discord API will reject completey empty messages, so some content is required.
796
+
797
+
-`text`: A string or a slice of strings.
798
+
-`section`: A layout block that shows text with one optional accessory: a button **OR** a thumbnail with the following keys:
799
+
-`text`: A string or a slice of strings.
800
+
-`button`: A Button object, check [cbutton](#cbutton).
801
+
-`thumbnail`: A sdict with the following keys:
802
+
-`media`: A string.
803
+
-`description`: A string.
804
+
-`spoiler`: A bool.
805
+
-`gallery`: Displays one or more media items with optional descriptions and spoiler flags with the following keys:
806
+
-`media`: A string.
807
+
-`description`: A string.
808
+
-`spoiler`: A bool.
809
+
-`file`: Attaches text files to the message and optionally displays them with the following keys:
810
+
-`content`: A string. (≤ 100,000 chars)
811
+
-`name`: A string. (.txt appended automatically)
812
+
-`separator`: Adds spacing between components with the following keys:
813
+
-`true`: large separator
814
+
-`false` or `nil`: small separator
815
+
-`container`: top-level layout component. containers offer the ability to visually encapsulate a collection of components and have an optional customizable accent color bar. with the following keys:
816
+
-`components`: [componentbuilder](#componentbuilder) or list of [componentbuilder](#componentbuilder).
817
+
-`color`: hex accent color (optional).
818
+
-`spoiler`: hides content until revealed (optional).
819
+
-`buttons`: Interactive buttons users can click. Can be single or multiple. see [cbutton](#cbutton).
820
+
-`menus`: Interactive menus users can select from. Can be single or multiple. see [cmenu](#cmenu).
821
+
-`interactive_components`: Mix of buttons and menus, auto-distributed. see [cbutton](#cbutton) and [cmenu](#cmenu).
822
+
-`allowed_mentions`: A sdict with the following keys:
823
+
-`users`: A slice of user IDs.
824
+
-`roles`: A slice of role IDs.
825
+
-`everyone`: A bool.
826
+
-`replied_user`: A bool.
827
+
-`reply`: A sdict with the following keys:
828
+
-`message_id`: A string.
829
+
-`thread_id`: A string.
830
+
-`silent`: A bool.
831
+
-`ephemeral`: A bool.
832
+
833
+
### Component Builder Functions
834
+
835
+
The `ComponentBuilder` object provides methods to construct, manipulate, and export Discord V2 message components programmatically. These methods allow you to build complex layouts incrementally and retrieve them in a format that Discord understands.
836
+
837
+
#### ComponentBuilder.Add
838
+
839
+
Adds a single component entry to the builder under the given key.
840
+
```yag
841
+
{{ $builder := componentBuilder }}
842
+
{{ $builder.Add "key" "value" }}
843
+
```
844
+
845
+
-`key` – The top-level key for the component (e.g., "text", "section", "buttons").
846
+
-`value` – The component data (string, sdict, Button, SelectMenu, etc.).
0 commit comments