Allow creating announcement channels (#2837)
This commit is contained in:
@@ -280,6 +280,39 @@ namespace Discord.Rest
|
||||
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
|
||||
return RestTextChannel.Create(client, guild, model);
|
||||
}
|
||||
|
||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null" />.</exception>
|
||||
public static async Task<RestNewsChannel> CreateNewsChannelAsync(IGuild guild, BaseDiscordClient client,
|
||||
string name, RequestOptions options, Action<TextChannelProperties> func = null)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(paramName: nameof(name));
|
||||
|
||||
var props = new TextChannelProperties();
|
||||
func?.Invoke(props);
|
||||
|
||||
var args = new CreateGuildChannelParams(name, ChannelType.News)
|
||||
{
|
||||
CategoryId = props.CategoryId,
|
||||
Topic = props.Topic,
|
||||
IsNsfw = props.IsNsfw,
|
||||
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.ToString(),
|
||||
Deny = overwrite.Permissions.DenyValue.ToString()
|
||||
}).ToArray()
|
||||
: Optional.Create<API.Overwrite[]>(),
|
||||
DefaultAutoArchiveDuration = props.AutoArchiveDuration
|
||||
};
|
||||
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
|
||||
return RestNewsChannel.Create(client, guild, model);
|
||||
}
|
||||
|
||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null" />.</exception>
|
||||
public static async Task<RestVoiceChannel> CreateVoiceChannelAsync(IGuild guild, BaseDiscordClient client,
|
||||
string name, RequestOptions options, Action<VoiceChannelProperties> func = null)
|
||||
|
||||
Reference in New Issue
Block a user