1- using System . Net ;
2- using System . Text ;
1+ using System . Text ;
32using Disc . NET . Client . SDK . Interfaces ;
43using Disc . NET . Client . SDK . Messages ;
54using Disc . NET . Shared . Configurations ;
87
98namespace Disc . NET . Client . SDK ;
109
11- public class Client : ClientBase , IClient
10+ public sealed class Client : ClientBase , IClient
1211{
1312 private readonly AppConfiguration _appConfiguration ;
13+ private readonly DiscNetSerializer _serializer = DiscNetSerializer . GetInstance ( ) ;
1414 public Client ( AppConfiguration appConfiguration , HttpClient client ) : base ( appConfiguration , client )
1515 {
1616 _appConfiguration = appConfiguration ;
@@ -23,7 +23,6 @@ public async Task SendMessageAsync(string channelId, ApiMessage message, Cancell
2323
2424 public async Task < ApiMessage ? > GetMessageAsync ( string channelId , string messageId , CancellationToken cancellation = default )
2525 {
26- var serializer = DiscNetSerializer . GetInstance ( ) ;
2726
2827 var response = await HttpClient . GetAsync ( $ "channels/{ channelId } /messages/{ messageId } ", cancellation )
2928 . ConfigureAwait ( false ) ;
@@ -33,7 +32,7 @@ public async Task SendMessageAsync(string channelId, ApiMessage message, Cancell
3332 throw new DiscNetClientSdkException ( error , response . StatusCode ) ;
3433 }
3534 var content = await response . Content . ReadAsStreamAsync ( cancellation ) . ConfigureAwait ( false ) ;
36- return await serializer . DeserializeAsync < ApiMessage > ( content , cancellation ) . ConfigureAwait ( false ) ;
35+ return await _serializer . DeserializeAsync < ApiMessage > ( content , cancellation ) . ConfigureAwait ( false ) ;
3736 }
3837
3938 public async Task RegisterGlobalSlashCommandAsync ( string commandJson , CancellationToken cancellation = default )
@@ -57,8 +56,7 @@ public async Task InteractionRespondingAsync(string interactionId, string intera
5756
5857 private async Task SendMessageAsync ( ApiMessage message , string channelId , CancellationToken cancellation = default )
5958 {
60- var serializer = DiscNetSerializer . GetInstance ( ) ;
61- var messageJson = serializer . Serialize ( message ) ;
59+ var messageJson = _serializer . Serialize ( message ) ;
6260 var content = new StringContent ( messageJson , Encoding . UTF8 , "application/json" ) ;
6361 var response = await HttpClient . PostAsync ( $ "channels/{ channelId } /messages", content , cancellation ) . ConfigureAwait ( false ) ;
6462 if ( ! response . IsSuccessStatusCode )
0 commit comments