Class ComponentBuilder
Represents a builder for creating a Discord.MessageComponent.
Assembly: Discord.Net.Core.dll​
View Source​
public class ComponentBuilder
Properties​
ActionRows​
Gets or sets the Action Rows for this Component Builder.
View Source​
public List<ActionRowBuilder> ActionRows { get; set; }
Fields​
MaxCustomIdLength​
The max length of a Discord.ButtonComponent.CustomId.
View Source​
public const int MaxCustomIdLength = 100
MaxActionRowCount​
The max amount of rows a message can have.
View Source​
public const int MaxActionRowCount = 5
Methods​
FromMessage(IMessage)​
Creates a new builder from a message.
View Source​
public static ComponentBuilder FromMessage(IMessage message)
Returns​
Discord.ComponentBuilder: The newly created builder.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IMessage | message | The message to create the builder from. |
FromComponents(IReadOnlyCollection<IMessageComponent>)​
Creates a new builder from the provided list of components.
View Source​
public static ComponentBuilder FromComponents(IReadOnlyCollection<IMessageComponent> components)
Returns​
Discord.ComponentBuilder: The newly created builder.
Parameters​
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyCollection<Discord.IMessageComponent> | components | The components to create the builder from. |
WithSelectMenu(String, List<SelectMenuOptionBuilder>, String, Int32, Int32, Boolean, Int32)​
Adds a Discord.SelectMenuBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
View Source​
public ComponentBuilder WithSelectMenu(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, int row = 0)
Returns​
Parameters​
Type | Name | Description |
---|---|---|
System.String | customId | The custom id of the menu. |
System.Collections.Generic.List<Discord.SelectMenuOptionBuilder> | options | The options of the menu. |
System.String | placeholder | The placeholder of the menu. |
System.Int32 | minValues | The min values of the placeholder. |
System.Int32 | maxValues | The max values of the placeholder. |
System.Boolean | disabled | Whether or not the menu is disabled. |
System.Int32 | row | The row to add the menu to. |
WithSelectMenu(SelectMenuBuilder, Int32)​
Adds a Discord.SelectMenuBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
View Source​
public ComponentBuilder WithSelectMenu(SelectMenuBuilder menu, int row = 0)
Returns​
Discord.ComponentBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
Discord.SelectMenuBuilder | menu | The menu to add. |
System.Int32 | row | The row to attempt to add this component on. |
WithButton(String, String, ButtonStyle, IEmote, String, Boolean, Int32)​
Adds a Discord.ButtonBuilder with specified parameters to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
View Source​
public ComponentBuilder WithButton(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, IEmote emote = null, string url = null, bool disabled = false, int row = 0)
Returns​
Discord.ComponentBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
System.String | label | The label text for the newly added button. |
System.String | customId | The custom id of the newly added button. |
Discord.ButtonStyle | style | The style of this newly added button. |
Discord.IEmote | emote | A Discord.IEmote to be used with this button. |
System.String | url | A URL to be used only if the Discord.ButtonStyle is a Link. |
System.Boolean | disabled | Whether or not the newly created button is disabled. |
System.Int32 | row | The row the button should be placed on. |
WithButton(ButtonBuilder, Int32)​
Adds a Discord.ButtonBuilder to the Discord.ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
View Source​
public ComponentBuilder WithButton(ButtonBuilder button, int row = 0)
Returns​
Discord.ComponentBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
Discord.ButtonBuilder | button | The button to add. |
System.Int32 | row | The row to add the button. |
Build()​
Builds this builder into a Discord.MessageComponent used to send your components.
View Source​
public MessageComponent Build()
Returns​
Discord.MessageComponent: A Discord.MessageComponent that can be sent with Discord.IMessageChannel.SendMessageAsync(System.String%2cSystem.Boolean%2cDiscord.Embed%2cDiscord.RequestOptions%2cDiscord.AllowedMentions%2cDiscord.MessageReference%2cDiscord.MessageComponent%2cDiscord.ISticker%5b%5d%2cDiscord.Embed%5b%5d)
.