diff --git a/DisCatSharp/Entities/Core/DisCatSharpBuilder.cs b/DisCatSharp/Entities/Core/DisCatSharpBuilder.cs
index c944e17f49..dc104a3d2d 100644
--- a/DisCatSharp/Entities/Core/DisCatSharpBuilder.cs
+++ b/DisCatSharp/Entities/Core/DisCatSharpBuilder.cs
@@ -33,10 +33,16 @@ public class DisCatSharpBuilder
///
internal string? ContentInternal { get; set; }
+ ///
+ /// Whether flags were changed.
+ ///
+ internal bool FlagsChanged { get; set; } = false;
+
///
/// The components of this builder.
///
- public IReadOnlyList Components => this.ComponentsInternal;
+ public IReadOnlyList Components
+ => this.ComponentsInternal;
///
/// The content of this builder.
@@ -56,17 +62,56 @@ public string? Content
///
/// The embeds for this builder.
///
- public IReadOnlyList Embeds => this.EmbedsInternal;
+ public IReadOnlyList Embeds
+ => this.EmbedsInternal;
///
/// The attachments of this builder.
///
- public IReadOnlyList Attachments => this.AttachmentsInternal;
+ public IReadOnlyList Attachments
+ => this.AttachmentsInternal;
///
/// The files of this builder.
///
- public IReadOnlyList Files => this.FilesInternal;
+ public IReadOnlyList Files
+ => this.FilesInternal;
+
+ ///
+ /// Whether this message should be using UI Kit.
+ ///
+ public bool IsUIKit
+ {
+ get => this.UI_KIT;
+ set
+ {
+ this.UI_KIT = value;
+ this.FlagsChanged = true;
+ }
+ }
+
+ ///
+ /// Whether this is using UI Kit.
+ ///
+ private bool UI_KIT { get; set; }
+
+ ///
+ /// Whether to suppress embeds.
+ ///
+ public bool EmbedsSuppressed
+ {
+ get => this.EMB_SUP;
+ set
+ {
+ this.EMB_SUP = value;
+ this.FlagsChanged = true;
+ }
+ }
+
+ ///
+ /// Whether embeds are suppressed.
+ ///
+ private bool EMB_SUP { get; set; }
///
/// Clears the components on this builder.
@@ -84,6 +129,7 @@ public virtual void Clear()
this.EmbedsInternal.Clear();
this.AttachmentsInternal.Clear();
this.ComponentsInternal.Clear();
+ this.FlagsChanged = false;
}
///
diff --git a/DisCatSharp/Entities/Interaction/Components/UIKit/DiscordMediaGalleryComponent.cs b/DisCatSharp/Entities/Interaction/Components/UIKit/DiscordMediaGalleryComponent.cs
index df03272c2f..b4c0ae1f99 100644
--- a/DisCatSharp/Entities/Interaction/Components/UIKit/DiscordMediaGalleryComponent.cs
+++ b/DisCatSharp/Entities/Interaction/Components/UIKit/DiscordMediaGalleryComponent.cs
@@ -46,6 +46,6 @@ public DiscordMediaGalleryComponent(IEnumerable items)
///
/// The content for the media gallery.
///
- [JsonProperty("content", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonProperty("items", NullValueHandling = NullValueHandling.Ignore)]
public IReadOnlyList Items { get; internal set; } = [];
}
diff --git a/DisCatSharp/Entities/Interaction/DiscordFollowupMessageBuilder.cs b/DisCatSharp/Entities/Interaction/DiscordFollowupMessageBuilder.cs
index 12d6b0a1b7..0d867f2fa8 100644
--- a/DisCatSharp/Entities/Interaction/DiscordFollowupMessageBuilder.cs
+++ b/DisCatSharp/Entities/Interaction/DiscordFollowupMessageBuilder.cs
@@ -12,11 +12,6 @@ namespace DisCatSharp.Entities;
///
public sealed class DiscordFollowupMessageBuilder : DisCatSharpBuilder
{
- ///
- /// Whether flags were changed.
- ///
- internal bool FlagsChanged = false;
-
///
/// Whether this followup message is text-to-speech.
///
@@ -37,21 +32,6 @@ public bool IsEphemeral
private bool EPH { get; set; }
- ///
- /// Whether to suppress embeds.
- ///
- public bool EmbedsSuppressed
- {
- get => this.EMB_SUP;
- set
- {
- this.EMB_SUP = value;
- this.FlagsChanged = true;
- }
- }
-
- private bool EMB_SUP { get; set; }
-
///
/// Whether to send as voice message.
/// You can't use that on your own, it needs DisCatSharp.Experimental.
@@ -128,14 +108,35 @@ public DiscordFollowupMessageBuilder AddComponents(IEnumerable contained more than 5 components.
public DiscordFollowupMessageBuilder AddComponents(IEnumerable components)
{
- var compArr = components.ToArray();
- var count = compArr.Length;
+ var cmpArr = components.ToArray();
+ var count = cmpArr.Length;
- if (count > 5)
- throw new ArgumentException("Cannot add more than 5 components per action row!");
+ if (this.IsUIKit)
+ {
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 10:
+ throw new ArgumentException("Cannot add more than 10 components!");
+ }
+
+ this.ComponentsInternal.AddRange(cmpArr);
+ }
+ else
+ {
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 5:
+ throw new ArgumentException("Cannot add more than 5 components per action row!");
+ }
+
+ var comp = new DiscordActionRowComponent(cmpArr);
+ this.ComponentsInternal.Add(comp);
+ }
- var arc = new DiscordActionRowComponent(compArr);
- this.ComponentsInternal.Add(arc);
return this;
}
diff --git a/DisCatSharp/Entities/Interaction/DiscordInteractionResponseBuilder.cs b/DisCatSharp/Entities/Interaction/DiscordInteractionResponseBuilder.cs
index 38ee592cf9..ed8818541a 100644
--- a/DisCatSharp/Entities/Interaction/DiscordInteractionResponseBuilder.cs
+++ b/DisCatSharp/Entities/Interaction/DiscordInteractionResponseBuilder.cs
@@ -14,11 +14,6 @@ public sealed class DiscordInteractionResponseBuilder : DisCatSharpBuilder
{
private readonly List _callbackHints = [];
- ///
- /// Whether flags were changed.
- ///
- internal bool FlagsChanged = false;
-
///
/// Constructs a new empty interaction response builder.
///
@@ -60,21 +55,6 @@ public bool IsEphemeral
private bool EPH { get; set; }
- ///
- /// Whether to suppress embeds.
- ///
- public bool EmbedsSuppressed
- {
- get => this.EMB_SUP;
- set
- {
- this.EMB_SUP = value;
- this.FlagsChanged = true;
- }
- }
-
- private bool EMB_SUP { get; set; }
-
///
/// Whether to send as silent message.
///
@@ -182,14 +162,35 @@ public DiscordInteractionResponseBuilder AddComponents(IEnumerableThrown when passing more than 5 components.
public DiscordInteractionResponseBuilder AddComponents(IEnumerable components)
{
- var compArr = components.ToArray();
- var count = compArr.Length;
+ var cmpArr = components.ToArray();
+ var count = cmpArr.Length;
- if (count > 5)
- throw new ArgumentException("Cannot add more than 5 components per action row!");
+ if (this.IsUIKit)
+ {
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 10:
+ throw new ArgumentException("Cannot add more than 10 components!");
+ }
+
+ this.ComponentsInternal.AddRange(cmpArr);
+ }
+ else
+ {
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 5:
+ throw new ArgumentException("Cannot add more than 5 components per action row!");
+ }
+
+ var comp = new DiscordActionRowComponent(cmpArr);
+ this.ComponentsInternal.Add(comp);
+ }
- var arc = new DiscordActionRowComponent(compArr);
- this.ComponentsInternal.Add(arc);
return this;
}
@@ -226,6 +227,17 @@ public DiscordInteractionResponseBuilder AsEphemeral()
return this;
}
+ ///
+ /// Sets that this builder should be using UI Kit.
+ ///
+ /// The current builder to chain calls with.
+ public DiscordInteractionResponseBuilder AsUIKitMessage()
+ {
+ this.FlagsChanged = true;
+ this.IsUIKit = true;
+ return this;
+ }
+
///
/// Sets the interaction response to suppress embeds.
///
diff --git a/DisCatSharp/Entities/Message/DiscordMessageBuilder.cs b/DisCatSharp/Entities/Message/DiscordMessageBuilder.cs
index c3ab565d87..9d7c37b397 100644
--- a/DisCatSharp/Entities/Message/DiscordMessageBuilder.cs
+++ b/DisCatSharp/Entities/Message/DiscordMessageBuilder.cs
@@ -39,11 +39,6 @@ public sealed class DiscordMessageBuilder : DisCatSharpBuilder
///
public bool IsVoiceMessage { get; private set; }
- ///
- /// Whether to send with ui kit.
- ///
- public bool IsUIKit { get; private set; }
-
///
/// Gets the Allowed Mentions for the message to be sent.
///
@@ -238,11 +233,13 @@ public DiscordMessageBuilder SuppressEmbeds(bool suppress = true)
}
///
- /// Sets the message to be send with ui kit.
+ /// Sets that this builder should be using UI Kit.
///
- public DiscordMessageBuilder AsUiKitMessage(bool asUiKitMessage = true)
+ /// The current builder to chain calls with.
+ public DiscordMessageBuilder AsUIKitMessage()
{
- this.IsUIKit = asUiKitMessage;
+ this.FlagsChanged = true;
+ this.IsUIKit = true;
return this;
}
diff --git a/DisCatSharp/Entities/Webhook/DiscordWebhookBuilder.cs b/DisCatSharp/Entities/Webhook/DiscordWebhookBuilder.cs
index 8baa44960f..29bd37bca2 100644
--- a/DisCatSharp/Entities/Webhook/DiscordWebhookBuilder.cs
+++ b/DisCatSharp/Entities/Webhook/DiscordWebhookBuilder.cs
@@ -16,11 +16,6 @@ public sealed class DiscordWebhookBuilder : DisCatSharpBuilder
{
private readonly List _appliedTags = [];
- ///
- /// Whether flags were changed.
- ///
- internal bool FlagsChanged = false;
-
///
/// Whether to keep previous attachments.
///
@@ -47,11 +42,6 @@ public DiscordWebhookBuilder()
///
public bool IsTts { get; private set; }
- ///
- /// Whether to suppress embeds.
- ///
- public bool EmbedsSuppressed { get; private set; }
-
///
/// Whether to send as silent message.
///
@@ -152,17 +142,43 @@ public DiscordWebhookBuilder AddComponents(IEnumerable compone
var cmpArr = components.ToArray();
var count = cmpArr.Length;
- switch (count)
+ if (this.IsUIKit)
{
- case 0:
- throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
- case > 5:
- throw new ArgumentException("Cannot add more than 5 components per action row!");
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 10:
+ throw new ArgumentException("Cannot add more than 10 components!");
+ }
+
+ this.ComponentsInternal.AddRange(cmpArr);
+ }
+ else
+ {
+ switch (count)
+ {
+ case 0:
+ throw new ArgumentOutOfRangeException(nameof(components), "You must provide at least one component");
+ case > 5:
+ throw new ArgumentException("Cannot add more than 5 components per action row!");
+ }
+
+ var comp = new DiscordActionRowComponent(cmpArr);
+ this.ComponentsInternal.Add(comp);
}
- var comp = new DiscordActionRowComponent(cmpArr);
- this.ComponentsInternal.Add(comp);
+ return this;
+ }
+ ///
+ /// Sets that this builder should be using UI Kit.
+ ///
+ /// The current builder to chain calls with.
+ public DiscordWebhookBuilder AsUIKitMessage()
+ {
+ this.FlagsChanged = true;
+ this.IsUIKit = true;
return this;
}
diff --git a/DisCatSharp/Net/Rest/DiscordApiClient.cs b/DisCatSharp/Net/Rest/DiscordApiClient.cs
index 589b6f304f..de1f31cded 100644
--- a/DisCatSharp/Net/Rest/DiscordApiClient.cs
+++ b/DisCatSharp/Net/Rest/DiscordApiClient.cs
@@ -5331,6 +5331,8 @@ internal async Task EditWebhookMessageAsync(ulong webhookId, str
flags |= MessageFlags.SuppressedEmbeds;
if (builder.NotificationsSuppressed)
flags |= MessageFlags.SuppressNotifications;
+ if (builder.IsUIKit)
+ flags |= MessageFlags.UIKit;
var pld = new RestWebhookMessageEditPayload
{
@@ -7051,6 +7053,8 @@ internal async Task CreateInteractionRespons
flags |= MessageFlags.SuppressedEmbeds;
if (builder.NotificationsSuppressed)
flags |= MessageFlags.SuppressNotifications;
+ if (builder.IsUIKit)
+ flags |= MessageFlags.UIKit;
}
var data = builder is not null
@@ -7285,6 +7289,8 @@ internal async Task CreateFollowupMessageAsync(ulong application
flags |= MessageFlags.SuppressedEmbeds;
if (builder.NotificationsSuppressed)
flags |= MessageFlags.SuppressNotifications;
+ if (builder.IsUIKit)
+ flags |= MessageFlags.UIKit;
var values = new Dictionary();
var pld = new RestFollowupMessageCreatePayload