public async Task DeleteSection() { GuildBson guild = await Database.LoadRecordsByGuildId(Context.Guild.Id); if (guild.CategoryId != null) { SocketCategoryChannel categoryChannel = Context.Guild.GetCategoryChannel(guild.CategoryId.Value); foreach (SocketGuildChannel channel in categoryChannel.Channels) { await channel.DeleteAsync(); } foreach (PropertyInfo info in guild.GetType().GetProperties() .Where(c => c.PropertyType == typeof(ulong?) && c.GetValue(guild) != null)) { guild.GetType().GetProperty(info.Name)?.SetValue(guild, (ulong?)1); } await categoryChannel.DeleteAsync(); } guild.CategoryId = null; await Database.UpdateGuild(guild); await SendSuccessAsync("Deleted Auditor sections."); }
public async Task DeleteCategory([Remainder] string category) { SocketCategoryChannel categoryChannel = Context.Guild.CategoryChannels.FirstOrDefault(c => c.Name == category); if (categoryChannel == null) { await Context.Channel.SendMessageAsync($"Cannot find a category with the name of '{category}'."); return; } foreach (SocketGuildChannel channel in categoryChannel.Channels) { await channel.DeleteAsync(); await Task.Delay(200); } await Task.Delay(500); await categoryChannel.DeleteAsync(); }