Skip to content

Commit ec92320

Browse files
committed
Update internals visibility and refactor API usage
Added 'Newtonsoft.Json' to InternalsVisibleTo.targets for internal visibility. Changed DiscordUnfurledMedia.Url to non-nullable. Refactored DiscordApiClient to use ToDiscordObject for deserialization, improving consistency.
1 parent 5509434 commit ec92320

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

DisCatSharp/Entities/Interaction/Components/V2Components/DiscordMediaGalleryComponent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public sealed class DiscordMediaGalleryComponent : DiscordComponent
1616
/// <summary>
1717
/// Constructs a new <see cref="DiscordMediaGalleryComponent" />.
1818
/// </summary>
19+
[JsonConstructor]
1920
internal DiscordMediaGalleryComponent()
2021
{
2122
this.Type = ComponentType.MediaGallery;
@@ -50,7 +51,7 @@ public DiscordMediaGalleryComponent(IEnumerable<DiscordMediaGalleryItem> items)
5051
/// The content for the media gallery.
5152
/// </summary>
5253
[JsonProperty("items", NullValueHandling = NullValueHandling.Ignore)]
53-
public IReadOnlyList<DiscordMediaGalleryItem> Items { get; internal set; } = [];
54+
public List<DiscordMediaGalleryItem> Items { get; internal set; } = [];
5455

5556
/// <summary>
5657
/// Assigns a unique id to the components.

DisCatSharp/Entities/Interaction/Components/V2Components/DiscordMediaGalleryItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public sealed class DiscordMediaGalleryItem
1010
/// <summary>
1111
/// Constructs a new empty <see cref="DiscordMediaGalleryItem" />.
1212
/// </summary>
13+
[JsonConstructor]
1314
internal DiscordMediaGalleryItem()
1415
{ }
1516

DisCatSharp/Entities/Interaction/Components/V2Components/DiscordUnfurledMediaItem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Newtonsoft.Json;
2+
13
namespace DisCatSharp.Entities;
24

35
/// <summary>
@@ -8,6 +10,7 @@ public sealed class DiscordUnfurledMediaItem : DiscordUnfurledMedia
810
/// <summary>
911
/// Constructs a new empty <see cref="DiscordUnfurledMediaItem" />.
1012
/// </summary>
13+
[JsonConstructor]
1114
internal DiscordUnfurledMediaItem()
1215
{ }
1316

DisCatSharp/Entities/Message/DiscordUnfurledMedia.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ public class DiscordUnfurledMedia: ObservableApiObject
1212
/// <summary>
1313
/// Constructs a new empty <see cref="DiscordUnfurledMedia" />.
1414
/// </summary>
15+
[JsonConstructor]
1516
internal DiscordUnfurledMedia()
1617
{ }
1718

1819
/// <summary>
1920
/// Gets the URL of the unfurled media.
2021
/// </summary>
2122
[JsonProperty("url", NullValueHandling = NullValueHandling.Ignore)]
22-
public DiscordUri? Url { get; internal set; }
23+
public DiscordUri Url { get; internal set; }
2324

2425
/// <summary>
2526
/// Gets the proxied URL of the unfurled media.

DisCatSharp/Net/Rest/DiscordApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static string BuildQueryString(Dictionary<string, string> values, bool p
125125
/// <param name="msgRaw">The raw message.</param>
126126
private DiscordMessage PrepareMessage(JToken msgRaw)
127127
{
128-
var author = msgRaw["author"].ToObject<TransportUser>();
128+
var author = msgRaw["author"].ToDiscordObject<TransportUser>();
129129
var ret = msgRaw.ToDiscordObject<DiscordMessage>();
130130
ret.Discord = this.Discord;
131131

0 commit comments

Comments
 (0)