From a0620be4e8c8e969caf219fb1afaff3002e4d188 Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Sun, 3 Jan 2021 23:28:08 +0000 Subject: [PATCH] adds try catch around delete message async for discord --- Core/bottypes/Discord/ChannelControl.cs | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Core/bottypes/Discord/ChannelControl.cs b/Core/bottypes/Discord/ChannelControl.cs index d57573b..c14fe68 100644 --- a/Core/bottypes/Discord/ChannelControl.cs +++ b/Core/bottypes/Discord/ChannelControl.cs @@ -14,6 +14,7 @@ namespace BSB.bottypes { if (AllowNewOutbound() == true) { + channelname = channelname.ToLowerInvariant(); channelname = String.Concat(channelname.Where(char.IsLetterOrDigit)); ITextChannel Channel = await FindTextChannel(channelname, catmap[catmapid], sender_id, TopicType).ConfigureAwait(false); @@ -126,16 +127,23 @@ namespace BSB.bottypes } if ((deleteMessages.Count > 0) || (slowDeleteMessages.Count > 0)) { - if (deleteMessages.Count > 0) - { - await chan.DeleteMessagesAsync(deleteMessages).ConfigureAwait(true); + try + { + if (deleteMessages.Count > 0) + { + await chan.DeleteMessagesAsync(deleteMessages).ConfigureAwait(true); + } + if (slowDeleteMessages.Count > 0) + { + foreach (IMessage slowdelmessage in slowDeleteMessages) + { + await chan.DeleteMessageAsync(slowdelmessage).ConfigureAwait(true); + } + } } - if (slowDeleteMessages.Count > 0) - { - foreach (IMessage slowdelmessage in slowDeleteMessages) - { - await chan.DeleteMessageAsync(slowdelmessage).ConfigureAwait(true); - } + catch + { + } empty = false; }