Resolve Issue #1188 (Allow Users to specify position when creating a new channel) (#1196)

* 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 documentation
This commit is contained in:
Nathan Solomon
2018-11-27 16:16:32 -06:00
committed by Christopher F
parent 10233f3a9a
commit a64ab6025b
5 changed files with 26 additions and 12 deletions

View File

@@ -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);
}
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
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));
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);
}