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