Update ChannelControl.cs

adds try catch around SendMessageAsync to deal with the channel http connection going away mid data stream
This commit is contained in:
Madpeterz 2021-03-25 04:45:57 +00:00
parent d077702f11
commit 3223191979

View file

@ -14,13 +14,19 @@ namespace BetterSecondBot.DiscordSupervisor
{ {
if (AllowNewOutbound() == true) if (AllowNewOutbound() == true)
{ {
try
channelname = channelname.ToLowerInvariant();
channelname = String.Concat(channelname.Where(char.IsLetterOrDigit));
ITextChannel Channel = await FindTextChannel(channelname, catmap[catmapid], sender_id, TopicType, false).ConfigureAwait(true);
if (Channel != null)
{ {
return await Channel.SendMessageAsync(message).ConfigureAwait(false); channelname = channelname.ToLowerInvariant();
channelname = String.Concat(channelname.Where(char.IsLetterOrDigit));
ITextChannel Channel = await FindTextChannel(channelname, catmap[catmapid], sender_id, TopicType, false).ConfigureAwait(true);
if (Channel != null)
{
return await Channel.SendMessageAsync(message).ConfigureAwait(false);
}
}
catch
{
return null;
} }
} }
return null; return null;