From fc70cb90d8954209b0b25c9420e15d268b3a616d Mon Sep 17 00:00:00 2001 From: TheUbMunster Date: Tue, 27 Jun 2023 18:32:04 -0600 Subject: [PATCH] Updated readme with the new settings, added another exception filter to the discordbot --- README.md | 7 +++++-- Server/DiscordBot.cs | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2e2cc47..2f13ae8 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,10 @@ Banlist: banned people are unable to join the server, default: false PersistShines/Moons: Allows the server to remember moon progress across crashes/restarts ### Discord -Note: Token and LogChannel needs to have quotes "" around it +Note: Token, LogChannel and CommandChannel need to have quotes "" around it Token: the token of the bot you want to load into, default: null Prefix: the bot prefix to be used, default: $ -LogChannel: logs the server console to that channel, default: null \ No newline at end of file +CommandChannel: allows discord commands, default: null +LogChannel/(AdminChannel): allows discord commands & logs the server console to that channel, default: null +LogCommands: log all executed commands to log handlers (discord, console), default: false +FilterOutNonIssueWarnings: filter out the nonsense warnings/errors? default: true \ No newline at end of file diff --git a/Server/DiscordBot.cs b/Server/DiscordBot.cs index b4da11c..b34b956 100644 --- a/Server/DiscordBot.cs +++ b/Server/DiscordBot.cs @@ -74,7 +74,8 @@ public class DiscordBot //filter it out to avoid logging it to discord. if (localSettings.FilterOutNonIssueWarnings) { - if (a.Message.Contains("Server requested a reconnect")) + //if (a.Message.Contains("Server requested a reconnect")) + if (a.Exception?.ToString().Contains("Server requested a reconnect") ?? false) { //This is to filter out this message. This warning is for discord server load balancing and isn't a problem @@ -82,6 +83,26 @@ public class DiscordBot //Warning[Discord: Gateway] at Discord.ConnectionManager.<> c__DisplayClass29_0.<< StartAsync > b__0 > d.MoveNext() return; } + else if (a.Exception?.ToString().Contains("The remote party closed the WebSocket connection without completing the close handshake.") ?? false) + { + //From Discord.NET discord's server, support: + //Discord does this normally and it effects all bots, as long as your bot is reconnecting + //after the error it is expected and should just be ignored. + + /*{18:21:02 Gateway System.Exception: WebSocket connection was closed + ---> System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. + at System.Net.WebSockets.ManagedWebSocket.ThrowIfEOFUnexpected(Boolean throwOnPrematureClosure) + at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure) + at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) + at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken) + at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) + at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state) + --- End of stack trace from previous location --- + at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken) + --- End of inner exception stack trace --- + at Discord.ConnectionManager.<>c__DisplayClass29_0.<b__0>d.MoveNext()}*/ + return; + } } string message = a.Message + (a.Exception != null ? "Exception: " + a.Exception.ToString() : ""); ConsoleColor col;