diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj
index b164aad27..346c49f2f 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.csproj
+++ b/src/Discord.Net.Core/Discord.Net.Core.csproj
@@ -8,7 +8,7 @@
net461;netstandard2.0;netstandard2.1netstandard2.0;netstandard2.1Discord.Net.Labs.Core
- 2.3.3
+ 2.3.4Discord.Net.Labs.Corehttps://github.com/Discord-Net-Labs/Discord.Net-LabsTemporary.png
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs
index 7151cc5af..c29ef44a2 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs
@@ -7,16 +7,21 @@ using System.Threading.Tasks;
namespace Discord
{
+ ///
+ /// Represents a Row for child components to live in.
+ ///
public class ActionRowComponent : IMessageComponent
{
- [JsonProperty("type")]
+ ///
public ComponentType Type { get; } = ComponentType.ActionRow;
- [JsonProperty("components")]
- public IReadOnlyCollection Components { get; internal set; }
+ ///
+ /// The child components in this row.
+ ///
+ public IReadOnlyCollection Components { get; internal set; }
internal ActionRowComponent() { }
- internal ActionRowComponent(IReadOnlyCollection components)
+ internal ActionRowComponent(List components)
{
this.Components = components;
}
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs
index 2e2b98f98..aede74687 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs
@@ -7,27 +7,45 @@ using System.Threading.Tasks;
namespace Discord
{
+ ///
+ /// Represents a Button.
+ ///
public class ButtonComponent : IMessageComponent
{
- [JsonProperty("type")]
+ ///
public ComponentType Type { get; } = ComponentType.Button;
- [JsonProperty("style")]
+ ///
+ /// The of this button, example buttons with each style can be found Here.
+ ///
public ButtonStyle Style { get; }
- [JsonProperty("label")]
+ ///
+ /// The label of the button, this is the text that is shown.
+ ///
public string Label { get; }
- [JsonProperty("emoji")]
+ ///
+ /// A that will be displayed with this button.
+ ///
public IEmote Emote { get; }
- [JsonProperty("custom_id")]
+ ///
+ /// A unique id that will be sent with a . This is how you know what button was pressed.
+ ///
public string CustomId { get; }
- [JsonProperty("url")]
+ ///
+ /// A URL for a button.
+ ///
+ ///
+ /// You cannot have a button with a URL and a CustomId.
+ ///
public string Url { get; }
- [JsonProperty("disabled")]
+ ///
+ /// Whether this button is disabled or not.
+ ///
public bool Disabled { get; }
internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool disabled)
@@ -39,5 +57,7 @@ namespace Discord
this.Url = url;
this.Disabled = disabled;
}
+
+
}
}
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
index 147667e72..a7da0d936 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
@@ -6,10 +6,19 @@ using System.Threading.Tasks;
namespace Discord
{
+ ///
+ /// Represents a builder for creating a .
+ ///
public class ComponentBuilder
{
+ ///
+ /// The max amount of rows a message can have.
+ ///
public const int MaxActionRowCount = 5;
+ ///
+ /// Gets or sets the Action Rows for this Component Builder.
+ ///
public List ActionRows
{
get => _actionRows;
@@ -25,11 +34,22 @@ namespace Discord
private List _actionRows { get; set; }
+ ///
+ /// Adds a button to the specified row.
+ ///
+ /// The label text for the newly added button.
+ /// The style of this newly added button.
+ /// A to be used with this button.
+ /// The custom id of the newly added button.
+ /// A URL to be used only if the is a Link.
+ /// Whether or not the newly created button is disabled.
+ /// The row the button should be placed on.
+ /// The current builder.
public ComponentBuilder WithButton(
string label,
+ string customId,
ButtonStyle style = ButtonStyle.Primary,
IEmote emote = null,
- string customId = null,
string url = null,
bool disabled = false,
int row = 0)
@@ -45,9 +65,20 @@ namespace Discord
return this.WithButton(button, row);
}
+ ///
+ /// Adds a button to the first row.
+ ///
+ /// The button to add to the first row.
+ /// The current builder.
public ComponentBuilder WithButton(ButtonBuilder button)
=> this.WithButton(button, 0);
+ ///
+ /// Adds a button to the specified row.
+ ///
+ /// The button to add.
+ /// The row to add the button.
+ /// The current builder.
public ComponentBuilder WithButton(ButtonBuilder button, int row)
{
var builtButton = button.Build();
@@ -75,6 +106,10 @@ namespace Discord
return this;
}
+ ///
+ /// Builds this builder into a used to send your components.
+ ///
+ /// A that can be sent with
public MessageComponent Build()
{
if (this._actionRows != null)
@@ -84,10 +119,20 @@ namespace Discord
}
}
+ ///
+ /// Represents a class used to build Action rows.
+ ///
public class ActionRowBuilder
{
+ ///
+ /// The max amount of child components this row can hold.
+ ///
public const int MaxChildCount = 5;
- public List Components
+
+ ///
+ /// Gets or sets the components inside this row.
+ ///
+ public List Components
{
get => _components;
set
@@ -99,33 +144,70 @@ namespace Discord
}
}
- private List _components { get; set; }
+ private List _components { get; set; }
- public ActionRowBuilder WithComponents(List components)
+ ///
+ /// Adds a list of components to the current row.
+ ///
+ /// The list of components to add.
+ /// The current builder.
+ public ActionRowBuilder WithComponents(List components)
{
this.Components = components;
return this;
}
- public ActionRowBuilder WithComponent(IMessageComponent component)
+ ///
+ /// Adds a component at the end of the current row.
+ ///
+ /// The component to add.
+ /// The current builder.
+ public ActionRowBuilder WithComponent(ButtonComponent component)
{
if (this.Components == null)
- this.Components = new List();
+ this.Components = new List();
this.Components.Add(component);
return this;
}
+ ///
+ /// Builds the current builder to a that can be used within a
+ ///
+ /// A that can be used within a
+ /// cannot be null.
+ /// There must be at least 1 component in a row.
public ActionRowComponent Build()
- => new ActionRowComponent(this._components);
+ {
+ if (this.Components == null)
+ throw new ArgumentNullException($"{nameof(Components)} cannot be null!");
+
+ if (this.Components.Count == 0)
+ throw new ArgumentException("There must be at least 1 component in a row");
+
+ return new ActionRowComponent(this._components);
+ }
}
+ ///
+ /// Represents a class used to build 's.
+ ///
public class ButtonBuilder
{
+ ///
+ /// The max length of a .
+ ///
public const int MaxLabelLength = 80;
+
+ ///
+ /// The max length of a .
+ ///
public const int MaxCustomIdLength = 100;
+ ///
+ /// Gets or sets the label of the current button.
+ ///
public string Label
{
get => _label;
@@ -139,6 +221,9 @@ namespace Discord
}
}
+ ///
+ /// Gets or sets the custom id of the current button.
+ ///
public string CustomId
{
get => _customId;
@@ -151,15 +236,36 @@ namespace Discord
}
}
+ ///
+ /// Gets or sets the of the current button.
+ ///
public ButtonStyle Style { get; set; }
+
+ ///
+ /// Gets or sets the of the current button.
+ ///
public IEmote Emote { get; set; }
+
+ ///
+ /// Gets or sets the url of the current button.
+ ///
public string Url { get; set; }
+
+ ///
+ /// Gets or sets whether the current button is disabled.
+ ///
public bool Disabled { get; set; }
private string _label;
private string _customId;
+ ///
+ /// Creates a button with the style.
+ ///
+ /// The label to use on the newly created link button.
+ /// The url for this link button to go to.
+ /// A builder with the newly created button.
public static ButtonBuilder CreateLinkButton(string label, string url)
{
var builder = new ButtonBuilder()
@@ -170,6 +276,12 @@ namespace Discord
return builder;
}
+ ///
+ /// Creates a button with the style.
+ ///
+ /// The label for this danger button.
+ /// The custom id for this danger button.
+ /// A builder with the newly created button.
public static ButtonBuilder CreateDangerButton(string label, string customId)
{
var builder = new ButtonBuilder()
@@ -180,6 +292,12 @@ namespace Discord
return builder;
}
+ ///
+ /// Creates a button with the style.
+ ///
+ /// The label for this primary button.
+ /// The custom id for this primary button.
+ /// A builder with the newly created button.
public static ButtonBuilder CreatePrimaryButton(string label, string customId)
{
var builder = new ButtonBuilder()
@@ -190,6 +308,12 @@ namespace Discord
return builder;
}
+ ///
+ /// Creates a button with the style.
+ ///
+ /// The label for this secondary button.
+ /// The custom id for this secondary button.
+ /// A builder with the newly created button.
public static ButtonBuilder CreateSecondaryButton(string label, string customId)
{
var builder = new ButtonBuilder()
@@ -200,6 +324,12 @@ namespace Discord
return builder;
}
+ ///
+ /// Creates a button with the style.
+ ///
+ /// The label for this success button.
+ /// The custom id for this success button.
+ /// A builder with the newly created button.
public static ButtonBuilder CreateSuccessButton(string label, string customId)
{
var builder = new ButtonBuilder()
@@ -210,41 +340,78 @@ namespace Discord
return builder;
}
+ ///
+ /// Sets the current buttons label to the specified text.
+ ///
+ /// The text for the label
+ /// The current builder.
public ButtonBuilder WithLabel(string label)
{
this.Label = label;
return this;
}
+ ///
+ /// Sets the current buttons style.
+ ///
+ /// The style for this builders button.
+ /// The current builder.
public ButtonBuilder WithStyle(ButtonStyle style)
{
this.Style = style;
return this;
}
+ ///
+ /// Sets the current buttons emote.
+ ///
+ /// The emote to use for the current button.
+ /// The current builder.
public ButtonBuilder WithEmote(IEmote emote)
{
this.Emote = emote;
return this;
}
+ ///
+ /// Sets the current buttons url.
+ ///
+ /// The url to use for the current button.
+ /// The current builder.
public ButtonBuilder WithUrl(string url)
{
this.Url = url;
return this;
}
+ ///
+ /// Sets the custom id of the current button.
+ ///
+ /// The id to use for the current button.
+ /// The current builder.
public ButtonBuilder WithCustomId(string id)
{
this.CustomId = id;
return this;
}
+
+ ///
+ /// Sets whether the current button is disabled.
+ ///
+ /// Whether the current button is disabled or not.
+ /// The current builder.
public ButtonBuilder WithDisabled(bool disabled)
{
this.Disabled = disabled;
return this;
}
+ ///
+ /// Builds this builder into a to be used in a .
+ ///
+ /// A to be used in a .
+ /// A button cannot contain a URL and a CustomId.
+ /// A button must have an Emote or a label.
public ButtonComponent Build()
{
if (string.IsNullOrEmpty(this.Label) && this.Emote == null)
@@ -255,7 +422,8 @@ namespace Discord
if (this.Style == ButtonStyle.Link && !string.IsNullOrEmpty(this.CustomId))
this.CustomId = null;
- else if (!string.IsNullOrEmpty(this.Url))
+
+ else if (this.Style != ButtonStyle.Link && !string.IsNullOrEmpty(this.Url)) // Thanks π΄ππͺππππΊπππππ :D
this.Url = null;
return new ButtonComponent(this.Style, this.Label, this.Emote, this.CustomId, this.Url, this.Disabled);
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs
index 1ee8dd953..82df2550e 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs
@@ -6,19 +6,25 @@ using System.Threading.Tasks;
namespace Discord
{
+ ///
+ /// Represents a component object used to send components with messages.
+ ///
public class MessageComponent
{
- public IReadOnlyCollection Components { get; }
+ ///
+ /// The components to be used in a message.
+ ///
+ public IReadOnlyCollection Components { get; }
internal MessageComponent(List components)
{
this.Components = components;
}
+ ///
+ /// Returns a empty .
+ ///
internal static MessageComponent Empty
=> new MessageComponent(new List());
-
- internal IMessageComponent[] ToModel()
- => this.Components.ToArray();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
index b632d6a18..1e4846a94 100644
--- a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
+++ b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
@@ -21,5 +21,10 @@ namespace Discord
/// Gets or sets the embed the message should display.
///
public Optional