From acfc3da27cc7dacbed8c9872a01f24a47043acbc Mon Sep 17 00:00:00 2001 From: Madpeter Date: Sat, 23 May 2020 17:27:47 +0100 Subject: [PATCH] adds a try catch around the create text channel call so if it fails it does not take out the bot. - Reported by Darl --- Core/bottypes/Discord/ChannelControl.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Core/bottypes/Discord/ChannelControl.cs b/Core/bottypes/Discord/ChannelControl.cs index 14bc710..3bfa5ad 100644 --- a/Core/bottypes/Discord/ChannelControl.cs +++ b/Core/bottypes/Discord/ChannelControl.cs @@ -119,9 +119,16 @@ namespace BSB.bottypes { display_topic = "" + channeltopictype + ":" + sender_id + ": Actions -> !clear, !close"; } - IGuildChannel channel = await DiscordServer.CreateTextChannelAsync(channelname, X => DiscordGetNewChannelProperies(X, channelname, display_topic, channeltopictype.ToLowerInvariant())); - ITextChannel Txtchan = await DiscordServer.GetTextChannelAsync(channel.Id); - return Txtchan; + try + { + IGuildChannel channel = await DiscordServer.CreateTextChannelAsync(channelname, X => DiscordGetNewChannelProperies(X, channelname, display_topic, channeltopictype.ToLowerInvariant())); + ITextChannel Txtchan = await DiscordServer.GetTextChannelAsync(channel.Id); + return Txtchan; + } + catch + { + return null; + } } protected void DiscordGetNewChannelProperies(TextChannelProperties C, string channelname, string channeltopic, string catname)