@@ -83,6 +83,7 @@ public partial class DiscordSocketClient : BaseSocketClient, IDiscordClient
83
83
internal bool AlwaysResolveStickers { get ; private set ; }
84
84
internal bool LogGatewayIntentWarnings { get ; private set ; }
85
85
internal bool SuppressUnknownDispatchWarnings { get ; private set ; }
86
+ internal bool IncludeRawPayloadOnGatewayErrors { get ; private set ; }
86
87
internal int AuditLogCacheSize { get ; private set ; }
87
88
88
89
internal new DiscordSocketApiClient ApiClient => base . ApiClient ;
@@ -158,6 +159,7 @@ private DiscordSocketClient(DiscordSocketConfig config, API.DiscordSocketApiClie
158
159
AlwaysResolveStickers = config . AlwaysResolveStickers ;
159
160
LogGatewayIntentWarnings = config . LogGatewayIntentWarnings ;
160
161
SuppressUnknownDispatchWarnings = config . SuppressUnknownDispatchWarnings ;
162
+ IncludeRawPayloadOnGatewayErrors = config . IncludeRawPayloadOnGatewayErrors ;
161
163
HandlerTimeout = config . HandlerTimeout ;
162
164
State = new ClientState ( 0 , 0 ) ;
163
165
Rest = new DiscordSocketRestClient ( config , ApiClient ) ;
@@ -3342,6 +3344,13 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
3342
3344
}
3343
3345
catch ( Exception ex )
3344
3346
{
3347
+ if ( IncludeRawPayloadOnGatewayErrors )
3348
+ {
3349
+ ex . Data [ "opcode" ] = opCode ;
3350
+ ex . Data [ "type" ] = type ;
3351
+ ex . Data [ "payload_data" ] = ( payload as JToken ) . ToString ( ) ;
3352
+ }
3353
+
3345
3354
await _gatewayLogger . ErrorAsync ( $ "Error handling { opCode } { ( type != null ? $ " ({ type } )" : "" ) } ", ex ) . ConfigureAwait ( false ) ;
3346
3355
}
3347
3356
}
0 commit comments