* Added ability to specify position when creating a channel * Adjusted categories to include guildproperties and allow specifying position when creating channel categories * fixed unimplemented methods (for CreateCategoryChannelAsync) and added appropriate documentationtags/2.0
| @@ -474,12 +474,13 @@ namespace Discord | |||||
| /// Creates a new channel category in this guild. | /// Creates a new channel category in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="name">The new name for the category.</param> | /// <param name="name">The new name for the category.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous creation operation. The task result contains the newly created | /// A task that represents the asynchronous creation operation. The task result contains the newly created | ||||
| /// category channel. | /// category channel. | ||||
| /// </returns> | /// </returns> | ||||
| Task<ICategoryChannel> CreateCategoryAsync(string name, RequestOptions options = null); | |||||
| Task<ICategoryChannel> CreateCategoryAsync(string name, Action<GuildChannelProperties> func = null, RequestOptions options = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of all the voice regions this guild can access. | /// Gets a collection of all the voice regions this guild can access. | ||||
| @@ -12,6 +12,8 @@ namespace Discord.API.Rest | |||||
| public ChannelType Type { get; } | public ChannelType Type { get; } | ||||
| [JsonProperty("parent_id")] | [JsonProperty("parent_id")] | ||||
| public Optional<ulong?> CategoryId { get; set; } | public Optional<ulong?> CategoryId { get; set; } | ||||
| [JsonProperty("position")] | |||||
| public Optional<int> Position { get; set; } | |||||
| //Text channels | //Text channels | ||||
| [JsonProperty("topic")] | [JsonProperty("topic")] | ||||
| @@ -163,6 +163,7 @@ namespace Discord.Rest | |||||
| CategoryId = props.CategoryId, | CategoryId = props.CategoryId, | ||||
| Topic = props.Topic, | Topic = props.Topic, | ||||
| IsNsfw = props.IsNsfw, | IsNsfw = props.IsNsfw, | ||||
| Position = props.Position | |||||
| }; | }; | ||||
| var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| return RestTextChannel.Create(client, guild, model); | return RestTextChannel.Create(client, guild, model); | ||||
| @@ -180,18 +181,26 @@ namespace Discord.Rest | |||||
| { | { | ||||
| CategoryId = props.CategoryId, | CategoryId = props.CategoryId, | ||||
| Bitrate = props.Bitrate, | Bitrate = props.Bitrate, | ||||
| UserLimit = props.UserLimit | |||||
| UserLimit = props.UserLimit, | |||||
| Position = props.Position | |||||
| }; | }; | ||||
| var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| return RestVoiceChannel.Create(client, guild, model); | return RestVoiceChannel.Create(client, guild, model); | ||||
| } | } | ||||
| /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | ||||
| public static async Task<RestCategoryChannel> CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client, | public static async Task<RestCategoryChannel> CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client, | ||||
| string name, RequestOptions options) | |||||
| string name, RequestOptions options, Action<GuildChannelProperties> func = null) | |||||
| { | { | ||||
| if (name == null) throw new ArgumentNullException(paramName: nameof(name)); | 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); | var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| return RestCategoryChannel.Create(client, guild, model); | return RestCategoryChannel.Create(client, guild, model); | ||||
| } | } | ||||
| @@ -441,13 +441,14 @@ namespace Discord.Rest | |||||
| /// Creates a category channel with the provided name. | /// Creates a category channel with the provided name. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="name">The name of the new channel.</param> | /// <param name="name">The name of the new channel.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | ||||
| /// <returns> | /// <returns> | ||||
| /// The created category channel. | /// The created category channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null) | |||||
| => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options); | |||||
| public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, Action<GuildChannelProperties> func = null, RequestOptions options = null) | |||||
| => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options, func); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of all the voice regions this guild can access. | /// Gets a collection of all the voice regions this guild can access. | ||||
| @@ -776,8 +777,8 @@ namespace Discord.Rest | |||||
| async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options) | async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options) | ||||
| => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); | => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options) | |||||
| => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); | |||||
| async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, Action<GuildChannelProperties> func, RequestOptions options) | |||||
| => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options) | async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options) | ||||
| @@ -561,14 +561,15 @@ namespace Discord.WebSocket | |||||
| /// Creates a new channel category in this guild. | /// Creates a new channel category in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="name">The new name for the category.</param> | /// <param name="name">The new name for the category.</param> | ||||
| /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | ||||
| /// <returns> | /// <returns> | ||||
| /// A task that represents the asynchronous creation operation. The task result contains the newly created | /// A task that represents the asynchronous creation operation. The task result contains the newly created | ||||
| /// category channel. | /// category channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null) | |||||
| => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options); | |||||
| public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, Action<GuildChannelProperties> func = null, RequestOptions options = null) | |||||
| => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options, func); | |||||
| internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model) | internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model) | ||||
| { | { | ||||
| @@ -1069,8 +1070,8 @@ namespace Discord.WebSocket | |||||
| async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options) | async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func, RequestOptions options) | ||||
| => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); | => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options) | |||||
| => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); | |||||
| async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, Action<GuildChannelProperties> func, RequestOptions options) | |||||
| => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options) | async Task<IReadOnlyCollection<IVoiceRegion>> IGuild.GetVoiceRegionsAsync(RequestOptions options) | ||||