v0.4.0
Update Path
Due to the following reasons, this version has made adjustments to the parameter types passed in some events
in BaseSocketClient
:
- Some parameters are always present and do not need to be wrapped with
Cacheable
, such asMessageDeleted
andUserConnected
. - The data sent by the gateway is incomplete, resulting in missing parameters in some events. These event parameters have been adjusted to entities wrapped with
Cacheable
to fix the issue of unknown entity IDs that cannot be obtained through the REST client API request for complete data. - The original processing logic for incomplete data sent by the gateway was to obtain complete data by initiating API requests through the REST client, which may cause performance issues or timeouts in large servers, such as
GuildMemberOnline
andGuildMemberOffline
. These event parameters have been adjusted to entities wrapped withCacheable
, and can be obtained on demand through theGetOrDownloadAsync
method. - Some event parameters are too specific, resulting in a mismatch of types and passing empty values, such as
ReactionAdded
. - Some event parameters are too general, such as
MessageDeleted
andUserConnected
, which can avoid unnecessary pattern matching. - Some event parameters are missing, such as
UserBanned
. - Some events pass excessively redundant parameters, such as
MessageButtonClicked
.
Full changes to the event parameters can be found in the appendix at the end of the document. All usages involving these events need to be updated accordingly.
All formatting methods in the KMarkdown formatting helper class Format
have been changed to extension methods, and a new optional parameter sanitize
has been added to support whether to escape special characters in the text, which defaults to true. The calling method of extension methods is still compatible with the original static method calling method. By default, all formatting methods escape special characters in the text that conflict with KMarkdown syntax to avoid syntax parsing errors. This feature is enabled by default and can be disabled through the sanitize
parameter. If the text parameter passed to this method has already escaped special characters, the sanitize
parameter should be set to false
, or the input parameter should be adjusted to the original unescaped text. Additionally, the logic of the Format.Quote
and Format.BlockQuote
methods have been adjusted. They will now insert line breaks and zero-width joiners (\u200d
) as needed within the text to maintain the display effect in the KOOK client. The formatting result of the Format.BlockQuote
method guarantees that the entire text block will be displayed as one quoted block in the KOOK client, while the formatting result of the Format.Quote
method will split the text into multiple quoted blocks based on empty lines, with the empty lines not included in the quoted blocks.
The Parse
and TryParse
methods in the CardJsonExtension
class have been renamed to ParseSingle
and TryParseSingle
to avoid conflicts with the ParseMany
and TryParseMany
methods used to parse multiple cards. All calls involving these methods need to be updated accordingly.
The Features
property type in IGuild
and IRecommendInfo
was originally object[]
, and is now implemented as the GuildFeatures
type. All calls involving these properties need to be updated accordingly.
The RestPresence
namespace has been corrected to Kook.Rest
. All calls involving RestPresence
need to update the namespace reference accordingly.
Added
- Added methods for managing friends and blocked users. For details, see the appendix at the end of the document.
- Added debug display text for the
Cacheable
andQuote
classes. - Added
MaxJoinedGuildDataFetchingRetryTimes
andJoinedGuildDataFetchingRetryDelay
properties toKookSocketConfig
for controlling the number of times and delay between retries for fetching data when joining a server. - Added
ParseMany
andTryParseMany
methods toCardJsonExtension
. - (Experimental feature) Added the
IVoiceRegion.MinimumBoostLevel
property. - (Experimental feature) Added
ValidateCardAsync
andValidateCardsAsync
methods toKookRestClient
.
Changed
- Changed the parameter types for some events in
BaseSocketClient
. For details, see the appendix at the end of the document. - The formatting methods in the
Format
helper class have been changed to extension methods, and a new optional sanitize parameter has been added to support escaping special characters in the text. The default value istrue
. - Renamed the
Parse
andTryParse
methods inCardJsonExtension
toParseSingle
andTryParseSingle
. - Implemented the
Features
property ofIGuild
andIRecommendInfo
as theGuildFeatures
type. - Corrected the namespace for
RestPresence
toKook.Rest
. - (Experimental feature) The
KookRestClient.GetAdminGuildsAsync
method now supports Bot authentication.
Fixed
- Fixed an issue where the results of the
Format.Quote
andFormat.BlockQuote
methods were displayed incorrectly in KOOK. - Fixed an issue where the error message in exceptions thrown by
CountdownModuleBuilder.Build
was incorrect. - Fixed an issue where
BaseSocketClient.DirectMessageUpdated
might pass an incorrect user entity. - Fixed an issue where the
Author
property was null in message-related events when the user was not cached. - Fixed an issue where
IGuild.OwnerId
is0
. - Fixed an issue where the
IsPinned
property was not set correctly inBaseSocketClient.Pinned
andBaseSocketClient.Unpinned
events. - Fixed an issue where the
IPresence.ActiveClient
property could be unintentionally cleared. - Fixed an issue where the debug display format of
IPresence
was incorrect. - Fixed an issue where the default implementation of
IRestClient
could throw an exception whenDEBUG_REST
preprocessor directive was enabled for debugging high-concurrency requests in the source code. - Fixed an issue where
Quote.Empty
was not a static property.
Optimized
- Fixed an issue with missing preprocessor directives in
KookRestApiClient
. - Optimized the
SocketUser.UpdateIntimacyAsync
method's implementation of theIUser
interface. - Improved the use of
NumberBooleanConverter
. KookSocketClient
logs warnings or the content of received packets when they are out of order or not handled correctly.- When printing exception packets,
KookSocketClient
uses the passed-inserializerOptions
serialization options. - Completed XML documentation for
BaseSocketClient
events.
Misc
- Due to the issue of missing field values when creating roles being fixed on the KOOK server side, commit 1726d5c has been reverted.
- Corrected some errors in the documentation.
- Fixed the issue where the test server created by integration testing was not properly deleted.
Appendix
Added APIs:
- Get all friends:
IKookClient.GetFriendsAsync
- Request to add a friend:
IUser.RequestFriendAsync
- Remove a friend:
IUser.RemoveFriendAsync
- Get all friend requests:
IKookClient.GetFriendRequestsAsync
- Accept a friend request:
IFriendRequest.AcceptAsync
- Decline a friend request:
IFriendRequest.DeclineAsync
- Get all blocked users:
IKookClient.GetBlockedUsersAsync
- Block a user:
IUser.BlockAsync
- Unblock a user:
IUser.UnblockAsync
Event parameter changes in BaseSocketClient
:
ReactionAdded
andReactionRemoved
Cacheable<IUserMessage, Guid>
→Cacheable<IMessage, ulong>
Cacheable<IMessageChannel, ulong>
→ISocketMessageChannel
DirectReactionAdded
andDirectReactionRemoved
Cacheable<IUserMessage, Guid>
→Cacheable<IMessage, ulong>
MessageDeleted
Cacheable<IMessageChannel, ulong>
→ISocketMessageChannel
MessageUpdated
Cacheable<IMessage, Guid>
→Cacheable<SocketMessage, Guid>
SocketMessage
→Cacheable<SocketMessage, Guid>
MessagePinned
andMessageUnpinned
Cacheable<IMessage, Guid>
→Cacheable<SocketMessage, Guid>
SocketMessage
→Cacheable<SocketMessage, Guid>
SocketGuildUser
→Cacheable<SocketGuildUser, ulong>
DirectMessageUpdated
SocketMessage
→Cacheable<SocketMessage, Guid>
UserLeft
SocketUser
→Cacheable<SocketUser, ulong>
UserBanned
IReadOnlyCollection<SocketUser>
→IReadOnlyCollection<Cacheable<SocketUser, ulong>>
SocketUser
→Cacheable<SocketUser, ulong>
- Add a new parameter of type
string
to represent the reason for adding to the blacklist.
UserUnbanned
IReadOnlyCollection<SocketUser>
→IReadOnlyCollection<Cacheable<SocketUser, ulong>>
SocketUser
→Cacheable<SocketUser, ulong>
UserUpdated
SocketUser
→Cacheable<SocketUser, ulong>
GuildMemberUpdated
SocketGuildUser
→Cacheable<SocketGuildUser, ulong>
GuildMemberOnline
andGuildMemberOffline
IReadOnlyCollection<SocketGuildUser>
→IReadOnlyCollection<Cacheable<SocketGuildUser, ulong>>
UserConnected
andUserDisconnected
SocketUser
→Cacheable<SocketGuildUser, ulong>
- Remove the
SocketGuild
parameter, please retrieve it fromSocketVoiceChannel.Guild
.
MessageButtonClicked
SocketUser
→Cacheable<SocketGuildUser, ulong>
IMessage
→Cacheable<IMessage, Guid>
- Remove the
SocketGuild
parameter, please retrieve it fromSocketVoiceChannel.Guild
.
DirectMessageButtonClicked
SocketUser
→Cacheable<SocketUser, ulong>
IMessage
→Cacheable<IMessage, Guid>
Full Changelog: v0.3.1...v0.4.0