From 94fe31d746e77ab764466bd1aa3993f6983eb6bf Mon Sep 17 00:00:00 2001 From: Still Hsu <341464@gmail.com> Date: Sat, 13 Oct 2018 00:20:30 +0800 Subject: [PATCH] Adjust according to comments See: https://github.com/RogueException/Discord.Net/pull/1159/files/6e76b45713ae95cf6fdfb96b57ed7095f6b6cc59#diff-58466c35787d448266d026692e467baa --- src/Discord.Net.Rest/API/Common/Overwrite.cs | 8 -------- .../Entities/Channels/ChannelHelper.cs | 11 +++++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/Overwrite.cs b/src/Discord.Net.Rest/API/Common/Overwrite.cs index bf5e85fef..1f3548a1c 100644 --- a/src/Discord.Net.Rest/API/Common/Overwrite.cs +++ b/src/Discord.Net.Rest/API/Common/Overwrite.cs @@ -13,13 +13,5 @@ namespace Discord.API public ulong Deny { get; set; } [JsonProperty("allow"), Int53] public ulong Allow { get; set; } - - public Overwrite(ulong targetId, PermissionTarget targetType, ulong allowValue, ulong denyValue) - { - TargetId = targetId; - TargetType = targetType; - Allow = allowValue; - Deny = denyValue; - } } } diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 5b108577b..9db286a9d 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -329,14 +329,17 @@ namespace Discord.Rest public static async Task SyncPermissionsAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options) { var category = await GetCategoryAsync(channel, client, options).ConfigureAwait(false); - if (category == null) return; + if (category == null) throw new InvalidOperationException("This channel does not have a parent channel."); var apiArgs = new ModifyGuildChannelParams { Overwrites = category.PermissionOverwrites - .Select(overwrite => new API.Overwrite(overwrite.TargetId, overwrite.TargetType, - overwrite.Permissions.AllowValue, overwrite.Permissions.DenyValue)) - .ToArray() + .Select(overwrite => new API.Overwrite{ + TargetId = overwrite.TargetId, + TargetType = overwrite.TargetType, + Allow = overwrite.Permissions.AllowValue, + Deny = overwrite.Permissions.DenyValue + }).ToArray() }; await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); }