feature: Add missing channel properties (#1596)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
/// <summary>
|
||||
@@ -30,5 +32,9 @@ namespace Discord
|
||||
/// is set.
|
||||
/// </remarks>
|
||||
public Optional<ulong?> CategoryId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the permission overwrites for this channel.
|
||||
/// </summary>
|
||||
public Optional<IEnumerable<Overwrite>> PermissionOverwrites { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Discord.API.Rest
|
||||
public Optional<ulong?> CategoryId { get; set; }
|
||||
[JsonProperty("position")]
|
||||
public Optional<int> Position { get; set; }
|
||||
[JsonProperty("permission_overwrites")]
|
||||
public Optional<Overwrite[]> Overwrites { get; set; }
|
||||
|
||||
//Text channels
|
||||
[JsonProperty("topic")]
|
||||
public Optional<string> Topic { get; set; }
|
||||
[JsonProperty("nsfw")]
|
||||
public Optional<bool> IsNsfw { get; set; }
|
||||
[JsonProperty("rate_limit_per_user")]
|
||||
public Optional<int> SlowModeInterval { get; set; }
|
||||
|
||||
//Voice channels
|
||||
[JsonProperty("bitrate")]
|
||||
|
||||
@@ -46,6 +46,15 @@ namespace Discord.Rest
|
||||
Topic = args.Topic,
|
||||
IsNsfw = args.IsNsfw,
|
||||
SlowModeInterval = args.SlowModeInterval,
|
||||
Overwrites = args.PermissionOverwrites.IsSpecified
|
||||
? args.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
|
||||
{
|
||||
TargetId = overwrite.TargetId,
|
||||
TargetType = overwrite.TargetType,
|
||||
Allow = overwrite.Permissions.AllowValue,
|
||||
Deny = overwrite.Permissions.DenyValue
|
||||
}).ToArray()
|
||||
: Optional.Create<API.Overwrite[]>(),
|
||||
};
|
||||
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
|
||||
}
|
||||
@@ -413,7 +422,8 @@ namespace Discord.Rest
|
||||
var apiArgs = new ModifyGuildChannelParams
|
||||
{
|
||||
Overwrites = category.PermissionOverwrites
|
||||
.Select(overwrite => new API.Overwrite{
|
||||
.Select(overwrite => new API.Overwrite
|
||||
{
|
||||
TargetId = overwrite.TargetId,
|
||||
TargetType = overwrite.TargetType,
|
||||
Allow = overwrite.Permissions.AllowValue,
|
||||
|
||||
@@ -176,7 +176,17 @@ namespace Discord.Rest
|
||||
CategoryId = props.CategoryId,
|
||||
Topic = props.Topic,
|
||||
IsNsfw = props.IsNsfw,
|
||||
Position = props.Position
|
||||
Position = props.Position,
|
||||
SlowModeInterval = props.SlowModeInterval,
|
||||
Overwrites = props.PermissionOverwrites.IsSpecified
|
||||
? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
|
||||
{
|
||||
TargetId = overwrite.TargetId,
|
||||
TargetType = overwrite.TargetType,
|
||||
Allow = overwrite.Permissions.AllowValue,
|
||||
Deny = overwrite.Permissions.DenyValue
|
||||
}).ToArray()
|
||||
: Optional.Create<API.Overwrite[]>(),
|
||||
};
|
||||
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
|
||||
return RestTextChannel.Create(client, guild, model);
|
||||
@@ -195,7 +205,16 @@ namespace Discord.Rest
|
||||
CategoryId = props.CategoryId,
|
||||
Bitrate = props.Bitrate,
|
||||
UserLimit = props.UserLimit,
|
||||
Position = props.Position
|
||||
Position = props.Position,
|
||||
Overwrites = props.PermissionOverwrites.IsSpecified
|
||||
? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
|
||||
{
|
||||
TargetId = overwrite.TargetId,
|
||||
TargetType = overwrite.TargetType,
|
||||
Allow = overwrite.Permissions.AllowValue,
|
||||
Deny = overwrite.Permissions.DenyValue
|
||||
}).ToArray()
|
||||
: Optional.Create<API.Overwrite[]>(),
|
||||
};
|
||||
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
|
||||
return RestVoiceChannel.Create(client, guild, model);
|
||||
@@ -211,7 +230,16 @@ namespace Discord.Rest
|
||||
|
||||
var args = new CreateGuildChannelParams(name, ChannelType.Category)
|
||||
{
|
||||
Position = props.Position
|
||||
Position = props.Position,
|
||||
Overwrites = props.PermissionOverwrites.IsSpecified
|
||||
? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
|
||||
{
|
||||
TargetId = overwrite.TargetId,
|
||||
TargetType = overwrite.TargetType,
|
||||
Allow = overwrite.Permissions.AllowValue,
|
||||
Deny = overwrite.Permissions.DenyValue
|
||||
}).ToArray()
|
||||
: Optional.Create<API.Overwrite[]>(),
|
||||
};
|
||||
|
||||
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user