diff --git a/src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs b/src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs
index 2ac6c8d52..1e789297b 100644
--- a/src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs
+++ b/src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs
@@ -1,4 +1,4 @@
-namespace Discord
+namespace Discord
{
///
/// Modify an IGuildChannel with the specified changes.
@@ -30,5 +30,9 @@
/// Sets the category for this channel
///
public Optional CategoryId { get; set; }
+ ///
+ /// Syncs the permission with the channel's parent (category).
+ ///
+ public Optional SyncWithCategory { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/API/Common/Overwrite.cs b/src/Discord.Net.Rest/API/Common/Overwrite.cs
index 1ba836127..bf5e85fef 100644
--- a/src/Discord.Net.Rest/API/Common/Overwrite.cs
+++ b/src/Discord.Net.Rest/API/Common/Overwrite.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CS1591
using Newtonsoft.Json;
namespace Discord.API
@@ -13,5 +13,13 @@ 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/API/Rest/ModifyGuildChannelParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs
index 120eeb3a8..41ae52eb8 100644
--- a/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs
@@ -12,5 +12,7 @@ namespace Discord.API.Rest
public Optional Position { get; set; }
[JsonProperty("parent_id")]
public Optional CategoryId { get; set; }
+ [JsonProperty("permission_overwrites")]
+ public Optional Overwrites { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
index dbbabbd72..9cfda487f 100644
--- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
@@ -19,6 +19,7 @@ namespace Discord.Rest
{
await client.ApiClient.DeleteChannelAsync(channel.Id, options).ConfigureAwait(false);
}
+
public static async Task ModifyAsync(IGuildChannel channel, BaseDiscordClient client,
Action func,
RequestOptions options)
@@ -31,6 +32,16 @@ namespace Discord.Rest
Position = args.Position,
CategoryId = args.CategoryId
};
+ if (args.SyncWithCategory.IsSpecified && args.SyncWithCategory.Value)
+ {
+ var categoryChannel = await channel.GetCategoryAsync().ConfigureAwait(false);
+ if (categoryChannel != null)
+ apiArgs.Overwrites = categoryChannel.PermissionOverwrites
+ .Select(overwrite => new API.Overwrite(overwrite.TargetId, overwrite.TargetType,
+ overwrite.Permissions.AllowValue, overwrite.Permissions.DenyValue))
+ .ToArray();
+ }
+
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}
public static async Task ModifyAsync(ITextChannel channel, BaseDiscordClient client,
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
index 026d03cc8..3dcb96354 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs
index 2163daf55..793248f88 100644
--- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs
+++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs
@@ -1,4 +1,4 @@
-using Discord.Rest;
+using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;