From 3665ef018c22f8c94f1367db869619473e1d0b49 Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sat, 12 Sep 2026 21:29:22 +0200 Subject: [PATCH 1/8] Add new PinnedMessagesProperties class and update related methods for pin management from the deprecated endpoints to the new ones --- NetCord/Rest/AllowedMentionsProperties.cs | 2 +- NetCord/Rest/PinnedMessagesProperties.cs | 13 +++++++++++ NetCord/Rest/RestClient.Channel.cs | 28 ++++++++++++++++++----- NetCord/Serialization.cs | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 NetCord/Rest/PinnedMessagesProperties.cs diff --git a/NetCord/Rest/AllowedMentionsProperties.cs b/NetCord/Rest/AllowedMentionsProperties.cs index 75a4d5aa8..67bb2dcb9 100644 --- a/NetCord/Rest/AllowedMentionsProperties.cs +++ b/NetCord/Rest/AllowedMentionsProperties.cs @@ -21,7 +21,7 @@ public partial class AllowedMentionsProperties /// /// A list of mentionable role IDs. Allows all roles if set to . /// - /// /// + /// /// /// If a role's property is set to , and is not set, it will not be mentioned regardless. /// diff --git a/NetCord/Rest/PinnedMessagesProperties.cs b/NetCord/Rest/PinnedMessagesProperties.cs new file mode 100644 index 000000000..e2fe392fd --- /dev/null +++ b/NetCord/Rest/PinnedMessagesProperties.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace NetCord.Rest; + +[GenerateMethodsForProperties] +public partial class PinnedMessagesProperties(DateTimeOffset? before, ulong? limit) +{ + [JsonPropertyName("before")] + public DateTimeOffset? Before { get; set; } = before; + + [JsonPropertyName("limit")] + public ulong? Limit { get; set; } = limit; +} diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index ef8b636c5..214be066c 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -645,7 +645,7 @@ public Task TriggerTypingAsync(ulong channelId, RestRequestProperties? propertie => SendRequestAsync(HttpMethod.Post, $"/channels/{channelId}/typing", null, new(channelId), properties, cancellationToken: cancellationToken); /// - /// /// Enters a typing scope for a channel, while waiting for the typing indicator to trigger. + /// Enters a typing scope for a channel, while waiting for the typing indicator to trigger. /// /// The ID of the channel to type in. /// Optional properties to customize the typing interval, can be . @@ -660,7 +660,7 @@ public ValueTask EnterTypingScopeAsync(ulong channelId, TypingScope } /// - /// /// Enters a typing scope for a channel, while waiting for the typing indicator to trigger. + /// Enters a typing scope for a channel, while waiting for the typing indicator to trigger. /// /// The ID of the channel to type in. /// Optional properties to customize the typing interval, can be . @@ -674,16 +674,29 @@ public IDisposable EnterTypingScope(ulong channelId, TypingScopeProperties? scop /// /// Retrieves all pinned messages in a channel. /// + /// + /// Requires the VIEW_CHANNEL permission. + /// If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned. + /// /// The ID of the channel to get pinned messages from. + /// Optional properties to customize the request, can be . /// Optional properties to customize the request, can be . /// A token that can be used to cancel the operation before it completes. [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] - public async Task> GetPinnedMessagesAsync(ulong channelId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) - => (await (await SendRequestAsync(HttpMethod.Get, $"/channels/{channelId}/pins", null, new(channelId), properties, cancellationToken: cancellationToken).ConfigureAwait(false)).ToObjectAsync(Serialization.Default.JsonMessageArray).ConfigureAwait(false)).Select(m => new RestMessage(m, this)).ToArray(); + public async Task> GetPinnedMessagesAsync(ulong channelId, PinnedMessagesProperties? pinsProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) + { + using (HttpContent? content = new JsonContent(pinsProperties, Serialization.Default.PinnedMessagesProperties)) + { + return (await (await SendRequestAsync(HttpMethod.Get, content, $"/channels/{channelId}/messages/pins", null, new(channelId),properties, cancellationToken: cancellationToken).ConfigureAwait(false)).ToObjectAsync(Serialization.Default.JsonMessageArray).ConfigureAwait(false)).Select(m => new RestMessage(m, this)).ToArray(); + } + } /// /// Pins a message in a channel. /// + /// + /// Requires the PIN_MESSAGES permission. Fires a event. + /// /// The ID of the channel containing the message. /// The ID of the message to pin. /// Optional properties to customize the request, can be . @@ -691,11 +704,14 @@ public async Task> GetPinnedMessagesAsync(ulong chann [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] [GenerateAlias([typeof(RestMessage)], nameof(RestMessage.ChannelId), nameof(RestMessage.Id), TypeNameOverride = "Message")] public Task PinMessageAsync(ulong channelId, ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) - => SendRequestAsync(HttpMethod.Put, $"/channels/{channelId}/pins/{messageId}", null, new(channelId), properties, cancellationToken: cancellationToken); + => SendRequestAsync(HttpMethod.Put, $"/channels/{channelId}/messages/pins/{messageId}", null, new(channelId), properties, cancellationToken: cancellationToken); /// /// Unpins a message from a channel. /// + /// + /// Requires the PIN_MESSAGES permission. Fires a event. + /// /// The ID of the channel containing the message. /// The ID of the message to unpin. /// Optional properties to customize the request, can be . @@ -703,7 +719,7 @@ public Task PinMessageAsync(ulong channelId, ulong messageId, RestRequestPropert [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] [GenerateAlias([typeof(RestMessage)], nameof(RestMessage.ChannelId), nameof(RestMessage.Id), TypeNameOverride = "Message")] public Task UnpinMessageAsync(ulong channelId, ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) - => SendRequestAsync(HttpMethod.Delete, $"/channels/{channelId}/pins/{messageId}", null, new(channelId), properties, cancellationToken: cancellationToken); + => SendRequestAsync(HttpMethod.Delete, $"/channels/{channelId}/messages/pins/{messageId}", null, new(channelId), properties, cancellationToken: cancellationToken); /// /// Adds a recipient to a group DM channel. diff --git a/NetCord/Serialization.cs b/NetCord/Serialization.cs index f8be6b8a0..e107dc75d 100644 --- a/NetCord/Serialization.cs +++ b/NetCord/Serialization.cs @@ -143,6 +143,7 @@ namespace NetCord; [JsonSerializable(typeof(JsonUser[]))] [JsonSerializable(typeof(BulkDeleteMessagesProperties))] [JsonSerializable(typeof(PermissionOverwriteProperties))] +[JsonSerializable(typeof(PinnedMessagesProperties))] [JsonSerializable(typeof(JsonRestInvite[]))] [JsonSerializable(typeof(InviteProperties))] [JsonSerializable(typeof(JsonRestInvite))] From 28ce128dbc89176c1829a70dc167f94eb9826a6d Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sat, 12 Sep 2026 22:30:06 +0200 Subject: [PATCH 2/8] Fix pinned messages handling: remove PinnedMessagesProperties, add new JsonChannelPins and JsonMessagePin models, and update RestClient methods for pagination support --- NetCord/Rest/JsonModels/JsonChannelPins.cs | 26 +++++++++++++ NetCord/Rest/JsonModels/JsonMessagePin.cs | 23 ++++++++++++ NetCord/Rest/MessagePin.cs | 19 ++++++++++ NetCord/Rest/PinnedMessagesProperties.cs | 13 ------- NetCord/Rest/RestClient.Channel.cs | 43 +++++++++++++++++++--- NetCord/Serialization.cs | 2 +- 6 files changed, 106 insertions(+), 20 deletions(-) create mode 100644 NetCord/Rest/JsonModels/JsonChannelPins.cs create mode 100644 NetCord/Rest/JsonModels/JsonMessagePin.cs create mode 100644 NetCord/Rest/MessagePin.cs delete mode 100644 NetCord/Rest/PinnedMessagesProperties.cs diff --git a/NetCord/Rest/JsonModels/JsonChannelPins.cs b/NetCord/Rest/JsonModels/JsonChannelPins.cs new file mode 100644 index 000000000..946a14269 --- /dev/null +++ b/NetCord/Rest/JsonModels/JsonChannelPins.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; + +using NetCord.JsonModels; + +namespace NetCord.Rest.JsonModels; + +/// +/// Represents a list of pinned messages in a channel. +/// +public class JsonChannelPins : JsonEntity +{ + /// + /// The list of pinned messages in the channel. + /// + [JsonPropertyName("items")] + public JsonMessagePin[] Items { get; set; } + + /// + /// Whether the list of pinned messages is partial. + /// + /// + /// true if there are more pinned messages to retrieve; otherwise, false. + /// + [JsonPropertyName("has_more")] + public bool HasMore { get; set; } +} \ No newline at end of file diff --git a/NetCord/Rest/JsonModels/JsonMessagePin.cs b/NetCord/Rest/JsonModels/JsonMessagePin.cs new file mode 100644 index 000000000..37b7e3536 --- /dev/null +++ b/NetCord/Rest/JsonModels/JsonMessagePin.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; + +using NetCord.JsonModels; + +namespace NetCord.Rest.JsonModels; + +/// +/// Represents a pinned message in a channel. +/// +public class JsonMessagePin : JsonEntity +{ + /// + /// The time the message was pinned. + /// + [JsonPropertyName("pinned_at")] + public DateTimeOffset PinnedAt { get; set; } + + /// + /// The pinned message. + /// + [JsonPropertyName("message")] + public JsonMessage Message { get; set; } +} \ No newline at end of file diff --git a/NetCord/Rest/MessagePin.cs b/NetCord/Rest/MessagePin.cs new file mode 100644 index 000000000..0d16f894b --- /dev/null +++ b/NetCord/Rest/MessagePin.cs @@ -0,0 +1,19 @@ +namespace NetCord.Rest; + +/// +/// Represents a message pin in a channel, containing the pinned message and the time it was pinned. +/// +public class MessagePin(JsonModels.JsonMessagePin jsonModel, RestClient client) : IJsonModel +{ + JsonModels.JsonMessagePin IJsonModel.JsonModel => jsonModel; + + /// + /// The time the message was pinned. + /// + public DateTimeOffset PinnedAt { get; } = jsonModel.PinnedAt; + + /// + /// The pinned message. + /// + public RestMessage Message { get; } = new(jsonModel.Message, client); +} diff --git a/NetCord/Rest/PinnedMessagesProperties.cs b/NetCord/Rest/PinnedMessagesProperties.cs deleted file mode 100644 index e2fe392fd..000000000 --- a/NetCord/Rest/PinnedMessagesProperties.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace NetCord.Rest; - -[GenerateMethodsForProperties] -public partial class PinnedMessagesProperties(DateTimeOffset? before, ulong? limit) -{ - [JsonPropertyName("before")] - public DateTimeOffset? Before { get; set; } = before; - - [JsonPropertyName("limit")] - public ulong? Limit { get; set; } = limit; -} diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 214be066c..58c6530e8 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -671,24 +671,55 @@ public IDisposable EnterTypingScope(ulong channelId, TypingScopeProperties? scop return new TypingScope(this, channelId, scopeProperties, properties); } + /// + /// Gets the first 50 pinned messages in a channel + /// + /// + /// This endpoint is deprecated. + /// + /// The ID of the channel to get pinned messages from. + /// Optional properties to customize the request, can be . + /// A token that can be used to cancel the operation before it completes. + [Obsolete("Use GetChannelPinsAsync instead, which supports pagination.", false)] + [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] + public async Task> GetPinnedMessagesAsync(ulong channelId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) + => (await (await SendRequestAsync(HttpMethod.Get, $"/channels/{channelId}/pins", null, new(channelId), properties, cancellationToken: cancellationToken).ConfigureAwait(false)).ToObjectAsync(Serialization.Default.JsonMessageArray).ConfigureAwait(false)).Select(m => new RestMessage(m, this)).ToArray(); + /// /// Retrieves all pinned messages in a channel. /// /// /// Requires the VIEW_CHANNEL permission. /// If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned. + /// You may need to paginate through the results if there are more than 50 pinned messages in the channel. /// /// The ID of the channel to get pinned messages from. - /// Optional properties to customize the request, can be . + /// Optional properties to customize result pagination, can be . /// Optional properties to customize the request, can be . /// A token that can be used to cancel the operation before it completes. [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] - public async Task> GetPinnedMessagesAsync(ulong channelId, PinnedMessagesProperties? pinsProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) + public async Task> GetChannelPinsAsync(ulong channelId, PaginationProperties? paginationProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) { - using (HttpContent? content = new JsonContent(pinsProperties, Serialization.Default.PinnedMessagesProperties)) - { - return (await (await SendRequestAsync(HttpMethod.Get, content, $"/channels/{channelId}/messages/pins", null, new(channelId),properties, cancellationToken: cancellationToken).ConfigureAwait(false)).ToObjectAsync(Serialization.Default.JsonMessageArray).ConfigureAwait(false)).Select(m => new RestMessage(m, this)).ToArray(); - } + paginationProperties = + PaginationProperties.PrepareWithDirectionValidation( + paginationProperties, + PaginationDirection.Before, + 50); + + return new OptimizedQueryPaginationAsyncEnumerable( + this, + paginationProperties, + async s => + { + var result = await s.ToObjectAsync(Serialization.Default.JsonChannelPins).ConfigureAwait(false); + return (result.Items.Select(m => new MessagePin(m, this)), result.HasMore); + }, + m => m.PinnedAt, + HttpMethod.Get, + $"/channels/{channelId}/messages/pins", + new(paginationProperties.BatchSize.GetValueOrDefault(), paginationProperties.Direction.GetValueOrDefault(), timestamp => timestamp.ToString("O")), + new(channelId), + properties); } /// diff --git a/NetCord/Serialization.cs b/NetCord/Serialization.cs index e107dc75d..c38ec6ba9 100644 --- a/NetCord/Serialization.cs +++ b/NetCord/Serialization.cs @@ -143,7 +143,6 @@ namespace NetCord; [JsonSerializable(typeof(JsonUser[]))] [JsonSerializable(typeof(BulkDeleteMessagesProperties))] [JsonSerializable(typeof(PermissionOverwriteProperties))] -[JsonSerializable(typeof(PinnedMessagesProperties))] [JsonSerializable(typeof(JsonRestInvite[]))] [JsonSerializable(typeof(InviteProperties))] [JsonSerializable(typeof(JsonRestInvite))] @@ -212,6 +211,7 @@ namespace NetCord; [JsonSerializable(typeof(JsonEntitlement[]))] [JsonSerializable(typeof(JsonSku[]))] [JsonSerializable(typeof(JsonAuthorizationInformation))] +[JsonSerializable(typeof(JsonChannelPins))] [JsonSerializable(typeof(StageInstanceProperties))] [JsonSerializable(typeof(StageInstanceOptions))] [JsonSerializable(typeof(JsonSticker))] From 8cec67bb6c4998ac48d154c54821c4b38f3c0006 Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sat, 12 Sep 2026 22:34:27 +0200 Subject: [PATCH 3/8] Remove redundant comment about pagination regarding the GetChannelPinsAsync method --- NetCord/Rest/RestClient.Channel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 58c6530e8..ad440041c 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -691,7 +691,6 @@ public async Task> GetPinnedMessagesAsync(ulong chann /// /// Requires the VIEW_CHANNEL permission. /// If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned. - /// You may need to paginate through the results if there are more than 50 pinned messages in the channel. /// /// The ID of the channel to get pinned messages from. /// Optional properties to customize result pagination, can be . From 8980bf2b42bb289928a4e428bb54d4d7d43db186 Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sat, 12 Sep 2026 22:37:13 +0200 Subject: [PATCH 4/8] Fix event reference in pinning methods documentation --- NetCord/Rest/RestClient.Channel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index ad440041c..4879dea0b 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -725,7 +725,7 @@ public async Task> GetChannelPinsAsync(ulong channe /// Pins a message in a channel. /// /// - /// Requires the PIN_MESSAGES permission. Fires a event. + /// Requires the PIN_MESSAGES permission. Fires a event. /// /// The ID of the channel containing the message. /// The ID of the message to pin. @@ -740,7 +740,7 @@ public Task PinMessageAsync(ulong channelId, ulong messageId, RestRequestPropert /// Unpins a message from a channel. /// /// - /// Requires the PIN_MESSAGES permission. Fires a event. + /// Requires the PIN_MESSAGES permission. Fires a event. /// /// The ID of the channel containing the message. /// The ID of the message to unpin. From 0273c288e6d57694b971f6b8df6422df7b95a905 Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sun, 13 Sep 2026 00:41:14 +0200 Subject: [PATCH 5/8] Apply batched suggestions from code review Co-authored-by: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> --- NetCord/Rest/JsonModels/JsonChannelPins.cs | 16 ++-------------- NetCord/Rest/JsonModels/JsonMessagePin.cs | 13 ++----------- NetCord/Rest/MessagePin.cs | 2 +- NetCord/Rest/RestClient.Channel.cs | 2 +- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/NetCord/Rest/JsonModels/JsonChannelPins.cs b/NetCord/Rest/JsonModels/JsonChannelPins.cs index 946a14269..00652eee1 100644 --- a/NetCord/Rest/JsonModels/JsonChannelPins.cs +++ b/NetCord/Rest/JsonModels/JsonChannelPins.cs @@ -4,23 +4,11 @@ namespace NetCord.Rest.JsonModels; -/// -/// Represents a list of pinned messages in a channel. -/// -public class JsonChannelPins : JsonEntity +internal class JsonChannelPins { - /// - /// The list of pinned messages in the channel. - /// [JsonPropertyName("items")] public JsonMessagePin[] Items { get; set; } - /// - /// Whether the list of pinned messages is partial. - /// - /// - /// true if there are more pinned messages to retrieve; otherwise, false. - /// [JsonPropertyName("has_more")] public bool HasMore { get; set; } -} \ No newline at end of file +} diff --git a/NetCord/Rest/JsonModels/JsonMessagePin.cs b/NetCord/Rest/JsonModels/JsonMessagePin.cs index 37b7e3536..4099daa7a 100644 --- a/NetCord/Rest/JsonModels/JsonMessagePin.cs +++ b/NetCord/Rest/JsonModels/JsonMessagePin.cs @@ -4,20 +4,11 @@ namespace NetCord.Rest.JsonModels; -/// -/// Represents a pinned message in a channel. -/// -public class JsonMessagePin : JsonEntity +public class JsonMessagePin { - /// - /// The time the message was pinned. - /// [JsonPropertyName("pinned_at")] public DateTimeOffset PinnedAt { get; set; } - /// - /// The pinned message. - /// [JsonPropertyName("message")] public JsonMessage Message { get; set; } -} \ No newline at end of file +} diff --git a/NetCord/Rest/MessagePin.cs b/NetCord/Rest/MessagePin.cs index 0d16f894b..e46633b61 100644 --- a/NetCord/Rest/MessagePin.cs +++ b/NetCord/Rest/MessagePin.cs @@ -10,7 +10,7 @@ public class MessagePin(JsonModels.JsonMessagePin jsonModel, RestClient client) /// /// The time the message was pinned. /// - public DateTimeOffset PinnedAt { get; } = jsonModel.PinnedAt; + public DateTimeOffset PinnedAt => jsonModel.PinnedAt; /// /// The pinned message. diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 4879dea0b..93149fd71 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -694,7 +694,7 @@ public async Task> GetPinnedMessagesAsync(ulong chann /// /// The ID of the channel to get pinned messages from. /// Optional properties to customize result pagination, can be . - /// Optional properties to customize the request, can be . + /// Optional properties to customize each request, can be . /// A token that can be used to cancel the operation before it completes. [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] public async Task> GetChannelPinsAsync(ulong channelId, PaginationProperties? paginationProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) From 092f45e74dd74315f242b527d0ba721b30c2708a Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sun, 13 Sep 2026 00:42:05 +0200 Subject: [PATCH 6/8] Remove deprecated GetPinnedMessagesAsync method Removed deprecated GetPinnedMessagesAsync method and its documentation. --- NetCord/Rest/RestClient.Channel.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 93149fd71..3e5ada039 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -671,20 +671,6 @@ public IDisposable EnterTypingScope(ulong channelId, TypingScopeProperties? scop return new TypingScope(this, channelId, scopeProperties, properties); } - /// - /// Gets the first 50 pinned messages in a channel - /// - /// - /// This endpoint is deprecated. - /// - /// The ID of the channel to get pinned messages from. - /// Optional properties to customize the request, can be . - /// A token that can be used to cancel the operation before it completes. - [Obsolete("Use GetChannelPinsAsync instead, which supports pagination.", false)] - [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] - public async Task> GetPinnedMessagesAsync(ulong channelId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) - => (await (await SendRequestAsync(HttpMethod.Get, $"/channels/{channelId}/pins", null, new(channelId), properties, cancellationToken: cancellationToken).ConfigureAwait(false)).ToObjectAsync(Serialization.Default.JsonMessageArray).ConfigureAwait(false)).Select(m => new RestMessage(m, this)).ToArray(); - /// /// Retrieves all pinned messages in a channel. /// From 571b6b3ff778f1735a25daf9473baf33c3f508f4 Mon Sep 17 00:00:00 2001 From: Andrzej Bansleben Date: Sun, 13 Sep 2026 03:26:27 +0200 Subject: [PATCH 7/8] Apply batched suggestions from code review Co-authored-by: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> --- NetCord/Rest/RestClient.Channel.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 3e5ada039..1460afcf6 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -682,15 +682,15 @@ public IDisposable EnterTypingScope(ulong channelId, TypingScopeProperties? scop /// Optional properties to customize result pagination, can be . /// Optional properties to customize each request, can be . /// A token that can be used to cancel the operation before it completes. - [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id))] - public async Task> GetChannelPinsAsync(ulong channelId, PaginationProperties? paginationProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) + [GenerateAlias([typeof(TextChannel)], nameof(TextChannel.Id), TypeNameOverride = "Channel")] + public IAsyncEnumerable GetChannelPinsAsync(ulong channelId, PaginationProperties? paginationProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default) { paginationProperties = PaginationProperties.PrepareWithDirectionValidation( paginationProperties, PaginationDirection.Before, 50); - + return new OptimizedQueryPaginationAsyncEnumerable( this, paginationProperties, @@ -702,7 +702,7 @@ public async Task> GetChannelPinsAsync(ulong channe m => m.PinnedAt, HttpMethod.Get, $"/channels/{channelId}/messages/pins", - new(paginationProperties.BatchSize.GetValueOrDefault(), paginationProperties.Direction.GetValueOrDefault(), timestamp => timestamp.ToString("O")), + new(paginationProperties.BatchSize.GetValueOrDefault(), paginationProperties.Direction.GetValueOrDefault(), timestamp => timestamp.ToString("s")), new(channelId), properties); } From ccbed3799d828012a280ea65ee5b3c00e71766ff Mon Sep 17 00:00:00 2001 From: KubaZ2 Date: Sun, 13 Sep 2026 16:14:02 +0200 Subject: [PATCH 8/8] Improve permissions in xml docs --- NetCord/Rest/RestClient.Channel.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NetCord/Rest/RestClient.Channel.cs b/NetCord/Rest/RestClient.Channel.cs index 1460afcf6..018be8336 100644 --- a/NetCord/Rest/RestClient.Channel.cs +++ b/NetCord/Rest/RestClient.Channel.cs @@ -675,8 +675,8 @@ public IDisposable EnterTypingScope(ulong channelId, TypingScopeProperties? scop /// Retrieves all pinned messages in a channel. /// /// - /// Requires the VIEW_CHANNEL permission. - /// If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned. + /// Requires the permission. + /// If the user is missing the permission in the channel, then no pins will be returned. /// /// The ID of the channel to get pinned messages from. /// Optional properties to customize result pagination, can be . @@ -711,7 +711,7 @@ public IAsyncEnumerable GetChannelPinsAsync(ulong channelId, Paginat /// Pins a message in a channel. /// /// - /// Requires the PIN_MESSAGES permission. Fires a event. + /// Requires the permission. Fires a event. /// /// The ID of the channel containing the message. /// The ID of the message to pin. @@ -726,7 +726,7 @@ public Task PinMessageAsync(ulong channelId, ulong messageId, RestRequestPropert /// Unpins a message from a channel. /// /// - /// Requires the PIN_MESSAGES permission. Fires a event. + /// Requires the permission. Fires a event. /// /// The ID of the channel containing the message. /// The ID of the message to unpin.