Skip to content

Commit 545b08c

Browse files
committed
exception message update
1 parent 91a45af commit 545b08c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Disc.NET.Client.SDK/Client.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ private async Task PostAsync(string json, string uri, CancellationToken cancella
8080

8181
private static string GetApiMessageJson(ApiMessage apiMessage, DiscNetSerializer serializer)
8282
{
83-
if (apiMessage.Components.Count > 5)
84-
{
85-
throw new DiscNetClientSdkException("A mensagem não pode conter mais de 5 componentes de nível superior.", HttpStatusCode.BadRequest);
86-
}
8783
var message = new
8884
{
8985
apiMessage.Content,

src/Disc.NET.Client.SDK/Messages/ApiMessage.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.Json.Serialization;
1+
using System.Net;
2+
using System.Text.Json.Serialization;
23
using Disc.NET.Client.SDK.Messages.Components;
34
using Disc.NET.Client.SDK.Messages.Embeds;
45
using Disc.NET.Shared.Constraints;
@@ -34,7 +35,10 @@ public List<object> MountComponents()
3435
NormalizeActionRows<ActionRowButtonComponentBuilder>(ActionRowConstraint.MAX_BUTTONS_PER_ACTION_ROW, message =>
3536
new ActionRowButtonComponentBuilder().AddButtons(message));
3637

37-
Components.ForEach(x => results.Add(x.Build()));
38+
if (Components.Count > 5)
39+
throw new DiscNetGenericException("The message cannot contain more than 5 top-level components.");
40+
41+
Components.ForEach(x => results.Add(x.Build()));
3842
return results;
3943
}
4044

0 commit comments

Comments
 (0)