diff --git a/Configuration.cs b/Configuration.cs
index 5683708..ac1f04b 100644
--- a/Configuration.cs
+++ b/Configuration.cs
@@ -38,6 +38,11 @@ class Configuration {
/// Amount of time to wait between background task runs within each shard.
///
public int BackgroundInterval { get; }
+ ///
+ /// Gets whether to show common connect/disconnect events and other related messages.
+ /// This is disabled in the public instance, but it's worth keeping enabled in self-hosted bots.
+ ///
+ public bool LogConnectionStatus { get; }
public Configuration() {
var args = CommandLineParameters.Parse(Environment.GetCommandLineArgs());
@@ -89,6 +94,7 @@ class Configuration {
StatusInterval = ReadConfKey(jc, nameof(StatusInterval), false) ?? 90;
MaxConcurrentOperations = ReadConfKey(jc, nameof(MaxConcurrentOperations), false) ?? 4;
BackgroundInterval = ReadConfKey(jc, nameof(BackgroundInterval), false) ?? 60;
+ LogConnectionStatus = ReadConfKey(jc, nameof(LogConnectionStatus), false) ?? true;
}
private static T? ReadConfKey(JObject jc, string key, [DoesNotReturnIf(true)] bool failOnEmpty) {
diff --git a/ShardInstance.cs b/ShardInstance.cs
index cd51665..8cd19d3 100644
--- a/ShardInstance.cs
+++ b/ShardInstance.cs
@@ -72,23 +72,27 @@ public sealed class ShardInstance : IDisposable {
private Task Client_Log(LogMessage arg) {
// Suppress certain messages
if (arg.Message != null) {
- switch (arg.Message) {
- case "Connecting":
- case "Connected":
- case "Ready":
- case "Disconnecting":
- case "Disconnected":
- case "Resumed previous session":
- case "Failed to resume previous session":
- case "Serializer Error": // The exception associated with this log appears a lot as of v3.2-ish
- return Task.CompletedTask;
+ if (!_manager.Config.LogConnectionStatus) {
+ switch (arg.Message) {
+ case "Connecting":
+ case "Connected":
+ case "Ready":
+ case "Disconnecting":
+ case "Disconnected":
+ case "Resumed previous session":
+ case "Failed to resume previous session":
+ case "Serializer Error": // The exception associated with this log appears a lot as of v3.2-ish
+ return Task.CompletedTask;
+ }
}
Log("Discord.Net", $"{arg.Severity}: {arg.Message}");
}
if (arg.Exception != null) {
- if (arg.Exception is GatewayReconnectException
- || arg.Exception.Message == "WebSocket connection was closed") return Task.CompletedTask;
+ if (!_manager.Config.LogConnectionStatus) {
+ if (arg.Exception is GatewayReconnectException || arg.Exception.Message == "WebSocket connection was closed")
+ return Task.CompletedTask;
+ }
Log("Discord.Net exception", arg.Exception.ToString());
}