Update relay.cs
add a try catch around discord webhook support in the event it kills itself
This commit is contained in:
parent
bdab4f14a0
commit
eccd78e98b
1 changed files with 11 additions and 4 deletions
|
|
@ -64,11 +64,18 @@ namespace BSB.bottypes
|
||||||
if ((myconfig.DiscordRelay_GroupUUID == group_uuid.ToString()) || (myconfig.DiscordRelay_GroupUUID == "*") || (myconfig.DiscordRelay_GroupUUID == "all"))
|
if ((myconfig.DiscordRelay_GroupUUID == group_uuid.ToString()) || (myconfig.DiscordRelay_GroupUUID == "*") || (myconfig.DiscordRelay_GroupUUID == "all"))
|
||||||
{
|
{
|
||||||
Group Gr = mygroups[group_uuid];
|
Group Gr = mygroups[group_uuid];
|
||||||
|
try
|
||||||
|
{
|
||||||
using var DWHclient = new DiscordWebhookClient(myconfig.DiscordRelay_URL);
|
using var DWHclient = new DiscordWebhookClient(myconfig.DiscordRelay_URL);
|
||||||
string SendMessage = "(" + Gr.Name + ") @" + sender_name + ":" + message + "";
|
string SendMessage = "(" + Gr.Name + ") @" + sender_name + ":" + message + "";
|
||||||
await DWHclient.SendMessageAsync(text: SendMessage).ConfigureAwait(false);
|
await DWHclient.SendMessageAsync(text: SendMessage).ConfigureAwait(false);
|
||||||
DWHclient.Dispose();
|
DWHclient.Dispose();
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
Info("Discord web hook has failed - marking as disabled untill next restart!");
|
||||||
|
myconfig.DiscordRelay_URL = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue