diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index a7206bd59..3b35796b9 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -474,12 +474,13 @@ namespace Discord
/// Creates a new channel category in this guild.
///
/// The new name for the category.
+ /// The delegate containing the properties to be applied to the channel upon its creation.
/// The options to be used when sending the request.
///
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// category channel.
///
- Task CreateCategoryAsync(string name, RequestOptions options = null);
+ Task CreateCategoryAsync(string name, Action func = null, RequestOptions options = null);
///
/// Gets a collection of all the voice regions this guild can access.
diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
index 05cdf4b8a..a102bd38d 100644
--- a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs
@@ -12,6 +12,8 @@ namespace Discord.API.Rest
public ChannelType Type { get; }
[JsonProperty("parent_id")]
public Optional CategoryId { get; set; }
+ [JsonProperty("position")]
+ public Optional Position { get; set; }
//Text channels
[JsonProperty("topic")]
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index c31fa89f2..affa74685 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -163,6 +163,7 @@ namespace Discord.Rest
CategoryId = props.CategoryId,
Topic = props.Topic,
IsNsfw = props.IsNsfw,
+ Position = props.Position
};
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestTextChannel.Create(client, guild, model);
@@ -180,18 +181,26 @@ namespace Discord.Rest
{
CategoryId = props.CategoryId,
Bitrate = props.Bitrate,
- UserLimit = props.UserLimit
+ UserLimit = props.UserLimit,
+ Position = props.Position
};
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestVoiceChannel.Create(client, guild, model);
}
/// is null.
public static async Task CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client,
- string name, RequestOptions options)
+ string name, RequestOptions options, Action func = null)
{
if (name == null) throw new ArgumentNullException(paramName: nameof(name));
- var args = new CreateGuildChannelParams(name, ChannelType.Category);
+ var props = new GuildChannelProperties();
+ func?.Invoke(props);
+
+ var args = new CreateGuildChannelParams(name, ChannelType.Category)
+ {
+ Position = props.Position
+ };
+
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestCategoryChannel.Create(client, guild, model);
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index bd70bf96b..a847998b5 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -441,13 +441,14 @@ namespace Discord.Rest
/// Creates a category channel with the provided name.
///
/// The name of the new channel.
+ /// The delegate containing the properties to be applied to the channel upon its creation.
/// The options to be used when sending the request.
/// is null.
///
/// The created category channel.
///
- public Task CreateCategoryChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);
+ public Task CreateCategoryChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options, func);
///
/// Gets a collection of all the voice regions this guild can access.
@@ -776,8 +777,8 @@ namespace Discord.Rest
async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options)
=> await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
///
- async Task IGuild.CreateCategoryAsync(string name, RequestOptions options)
- => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateCategoryAsync(string name, Action func, RequestOptions options)
+ => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false);
///
async Task> IGuild.GetVoiceRegionsAsync(RequestOptions options)
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 412f3acff..4e4124679 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -561,14 +561,15 @@ namespace Discord.WebSocket
/// Creates a new channel category in this guild.
///
/// The new name for the category.
+ /// The delegate containing the properties to be applied to the channel upon its creation.
/// The options to be used when sending the request.
/// is null.
///
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// category channel.
///
- public Task CreateCategoryChannelAsync(string name, RequestOptions options = null)
- => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);
+ public Task CreateCategoryChannelAsync(string name, Action func = null, RequestOptions options = null)
+ => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options, func);
internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model)
{
@@ -1069,8 +1070,8 @@ namespace Discord.WebSocket
async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options)
=> await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false);
///
- async Task IGuild.CreateCategoryAsync(string name, RequestOptions options)
- => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);
+ async Task IGuild.CreateCategoryAsync(string name, Action func, RequestOptions options)
+ => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false);
///
async Task> IGuild.GetVoiceRegionsAsync(RequestOptions options)