From ac39256566d8491b1c07a2a467f090c9a957732d Mon Sep 17 00:00:00 2001 From: Jedimaster4559 Date: Sat, 24 Nov 2018 00:57:06 -0600 Subject: [PATCH] Adjusted categories to include guildproperties and allow specifying position when creating channel categories --- src/Discord.Net.Core/Entities/Guilds/IGuild.cs | 3 ++- src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index 58922213e..affa74685 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -189,11 +189,18 @@ namespace Discord.Rest } /// 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); }