From 9a2421e8673e0c8b67ebda2d38c13202fd803d0f Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 28 May 2016 14:25:09 +0200 Subject: [PATCH] fixed cleanv+t crash --- .../Commands/VoicePlusTextCommand.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs b/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs index f62b9ba6..44419682 100644 --- a/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs @@ -6,6 +6,7 @@ using NadekoBot.Modules.Permissions.Classes; using System; using System.Linq; using System.Text.RegularExpressions; +using System.Threading.Tasks; using ChPermOverride = Discord.ChannelPermissionOverrides; namespace NadekoBot.Modules.Administration.Commands @@ -91,12 +92,26 @@ namespace NadekoBot.Modules.Administration.Commands .AddCheck(SimpleCheckers.ManageChannels()) .Do(async e => { + if (!e.Server.CurrentUser.ServerPermissions.ManageChannels) + { + await e.Channel.SendMessage("`I have insufficient permission to do that.`"); + return; + } + var allTxtChannels = e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice")); var validTxtChannelNames = e.Server.VoiceChannels.Select(c => GetChannelName(c.Name)); var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name)); - invalidTxtChannels.ForEach(async c => await c.Delete()); + foreach (var c in invalidTxtChannels) + { + try + { + await c.Delete(); + } + catch { } + await Task.Delay(500); + } await e.Channel.SendMessage("`Done.`"); });