Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration toggle to suppress Unknown dispatch warnings #2162

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public partial class DiscordSocketClient : BaseSocketClient, IDiscordClient
internal bool AlwaysDownloadDefaultStickers { get; private set; }
internal bool AlwaysResolveStickers { get; private set; }
internal bool LogGatewayIntentWarnings { get; private set; }
internal bool SuppressUnknownDispatchWarnings { get; private set; }
internal new DiscordSocketApiClient ApiClient => base.ApiClient;
/// <inheritdoc />
public override IReadOnlyCollection<SocketGuild> Guilds => State.Guilds;
Expand Down Expand Up @@ -150,6 +151,7 @@ private DiscordSocketClient(DiscordSocketConfig config, API.DiscordSocketApiClie
AlwaysDownloadDefaultStickers = config.AlwaysDownloadDefaultStickers;
AlwaysResolveStickers = config.AlwaysResolveStickers;
LogGatewayIntentWarnings = config.LogGatewayIntentWarnings;
SuppressUnknownDispatchWarnings = config.SuppressUnknownDispatchWarnings;
HandlerTimeout = config.HandlerTimeout;
State = new ClientState(0, 0);
Rest = new DiscordSocketRestClient(config, ApiClient);
Expand Down Expand Up @@ -2771,7 +2773,7 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty

#region Others
default:
await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false);
if(!SuppressUnknownDispatchWarnings) await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false);
break;
#endregion
}
Expand Down
5 changes: 5 additions & 0 deletions src/Discord.Net.WebSocket/DiscordSocketConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ public int MaxWaitBetweenGuildAvailablesBeforeReady
/// </summary>
public bool LogGatewayIntentWarnings { get; set; } = true;

/// <summary>
/// Gets or sets whether or not Unknown Dispatch event messages should be logged.
/// </summary>
public bool SuppressUnknownDispatchWarnings { get; set; } = true;

/// <summary>
/// Initializes a new instance of the <see cref="DiscordSocketConfig"/> class with the default configuration.
/// </summary>
Expand Down