Browse Source

Adjust according to comments

See: 6e76b45713 (diff-58466c35787d448266d026692e467baa)
pull/1159/head
Still Hsu 7 years ago
parent
commit
94fe31d746
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
2 changed files with 7 additions and 12 deletions
  1. +0
    -8
      src/Discord.Net.Rest/API/Common/Overwrite.cs
  2. +7
    -4
      src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs

+ 0
- 8
src/Discord.Net.Rest/API/Common/Overwrite.cs View File

@@ -13,13 +13,5 @@ namespace Discord.API
public ulong Deny { get; set; } public ulong Deny { get; set; }
[JsonProperty("allow"), Int53] [JsonProperty("allow"), Int53]
public ulong Allow { get; set; } public ulong Allow { get; set; }

public Overwrite(ulong targetId, PermissionTarget targetType, ulong allowValue, ulong denyValue)
{
TargetId = targetId;
TargetType = targetType;
Allow = allowValue;
Deny = denyValue;
}
} }
} }

+ 7
- 4
src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs View File

@@ -329,14 +329,17 @@ namespace Discord.Rest
public static async Task SyncPermissionsAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options) public static async Task SyncPermissionsAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options)
{ {
var category = await GetCategoryAsync(channel, client, options).ConfigureAwait(false); 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 var apiArgs = new ModifyGuildChannelParams
{ {
Overwrites = category.PermissionOverwrites 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); await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
} }


Loading…
Cancel
Save