Browse Source

Adjusted categories to include guildproperties and allow specifying position when creating channel categories

pull/1196/head
Jedimaster4559 6 years ago
parent
commit
ac39256566
2 changed files with 11 additions and 3 deletions
  1. +2
    -1
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +9
    -2
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs

+ 2
- 1
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -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.


+ 9
- 2
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -189,11 +189,18 @@ namespace Discord.Rest
} }
/// <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);
} }


Loading…
Cancel
Save