From eccd78e98b6f7a222717e49bef87bdced0d96801 Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Sun, 20 Dec 2020 09:30:19 +0000 Subject: [PATCH] Update relay.cs add a try catch around discord webhook support in the event it kills itself --- Core/bottypes/Discord/relay.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Core/bottypes/Discord/relay.cs b/Core/bottypes/Discord/relay.cs index f963019..bb1a98b 100644 --- a/Core/bottypes/Discord/relay.cs +++ b/Core/bottypes/Discord/relay.cs @@ -64,10 +64,17 @@ namespace BSB.bottypes if ((myconfig.DiscordRelay_GroupUUID == group_uuid.ToString()) || (myconfig.DiscordRelay_GroupUUID == "*") || (myconfig.DiscordRelay_GroupUUID == "all")) { Group Gr = mygroups[group_uuid]; - using var DWHclient = new DiscordWebhookClient(myconfig.DiscordRelay_URL); - string SendMessage = "(" + Gr.Name + ") @" + sender_name + ":" + message + ""; - await DWHclient.SendMessageAsync(text: SendMessage).ConfigureAwait(false); - DWHclient.Dispose(); + try + { + using var DWHclient = new DiscordWebhookClient(myconfig.DiscordRelay_URL); + string SendMessage = "(" + Gr.Name + ") @" + sender_name + ":" + message + ""; + await DWHclient.SendMessageAsync(text: SendMessage).ConfigureAwait(false); + DWHclient.Dispose(); + } + catch { + Info("Discord web hook has failed - marking as disabled untill next restart!"); + myconfig.DiscordRelay_URL = ""; + } } } }