/// <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, Action <GuildChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var props = new GuildChannelProperties(); func?.Invoke(props); var args = new CreateGuildChannelParams(name, ChannelType.Category) { 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.ToString(), Deny = overwrite.Permissions.DenyValue.ToString() }).ToArray() : Optional.Create <API.Overwrite[]>(), }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestCategoryChannel.Create(client, guild, model)); }
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestVoiceChannel> CreateVoiceChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <VoiceChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } VoiceChannelProperties props = new VoiceChannelProperties(); func?.Invoke(props); CreateGuildChannelParams args = new CreateGuildChannelParams(name, ChannelType.Voice) { CategoryId = props.CategoryId, Bitrate = props.Bitrate, UserLimit = props.UserLimit, Position = props.Position, Overwrites = props.PermissionOverwrites.IsSpecified ? props.PermissionOverwrites.Value.Select(overwrite => new API.OverwriteJson { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue, Deny = overwrite.Permissions.DenyValue }).ToArray() : Optional.Create <API.OverwriteJson[]>(), }; ChannelJson 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) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var args = new CreateGuildChannelParams(name, ChannelType.Category); var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestCategoryChannel.Create(client, guild, model)); }
public async Task <IVoiceChannel> CreateVoiceChannelAsync(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } var args = new CreateGuildChannelParams { Name = name, Type = ChannelType.Voice }; var model = await Discord.ApiClient.CreateGuildChannelAsync(Id, args).ConfigureAwait(false); return(new VoiceChannel(this, model)); }
public async Task <IActionResult> CreateGuildChannelAsync(Snowflake guildId, [FromBody] CreateGuildChannelParams args) { args.Validate(); return(Ok(new Channel { Bitrate = args.Bitrate, GuildId = guildId, IsNsfw = args.IsNsfw, Name = args.Name, ParentId = args.ParentId, PermissionOverwrites = args.PermissionOverwrites, Topic = args.Topic, Type = args.Type, UserLimit = args.UserLimit })); }
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestVoiceChannel> CreateVoiceChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <VoiceChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var props = new VoiceChannelProperties(); func?.Invoke(props); var args = new CreateGuildChannelParams(name, ChannelType.Voice) { CategoryId = props.CategoryId, Bitrate = props.Bitrate, UserLimit = props.UserLimit }; 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 <RestTextChannel> CreateTextChannelAsync(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.Text) { CategoryId = props.CategoryId, Topic = props.Topic, IsNsfw = props.IsNsfw, }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestTextChannel.Create(client, guild, model)); }