/// <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, 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(RestVoiceChannel.Create(client, guild, model)); }
internal new static RestVoiceChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { var entity = new RestVoiceChannel(discord, guild, model.Id); entity.Update(model); return(entity); }
internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { return(model.Type switch { ChannelType.News => RestNewsChannel.Create(discord, guild, model), ChannelType.Text => RestTextChannel.Create(discord, guild, model), ChannelType.Voice => RestVoiceChannel.Create(discord, guild, model), ChannelType.Stage => RestStageChannel.Create(discord, guild, model), ChannelType.Category => RestCategoryChannel.Create(discord, guild, model), ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread => RestThreadChannel.Create(discord, guild, model), _ => new RestGuildChannel(discord, guild, model.Id), });
public static async Task <RestVoiceChannel> CreateVoiceChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options) { if (name == null) { throw new ArgumentNullException(nameof(name)); } var args = new CreateGuildChannelParams(name, ChannelType.Voice); var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestVoiceChannel.Create(client, guild, model)); }
internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { switch (model.Type) { case ChannelType.Text: return(RestTextChannel.Create(discord, guild, model)); case ChannelType.Voice: return(RestVoiceChannel.Create(discord, guild, model)); default: throw new InvalidOperationException("Unknown guild channel type"); } }
internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { switch (model.Type) { case ChannelType.Text: return(RestTextChannel.Create(discord, guild, model)); case ChannelType.Voice: return(RestVoiceChannel.Create(discord, guild, model)); default: // TODO: Channel categories return(new RestGuildChannel(discord, guild, model.Id)); } }
/// <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)); }
/// <inheritdoc /> public Task SyncPermissionsAsync(RequestOptions options = null) => RestVoiceChannel.SyncPermissionsAsync(options);
/// <summary> /// Converts an existing <see cref="RestVoiceChannel"/> to an abstracted <see cref="IRestVoiceChannel"/> value. /// </summary> /// <param name="restVoiceChannel">The existing <see cref="RestVoiceChannel"/> to be abstracted.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="restVoiceChannel"/>.</exception> /// <returns>An <see cref="IRestVoiceChannel"/> that abstracts <paramref name="restVoiceChannel"/>.</returns> public static IRestVoiceChannel Abstract(this RestVoiceChannel restVoiceChannel) => new RestVoiceChannelAbstraction(restVoiceChannel);
/// <inheritdoc /> public Task ModifyAsync(Action <VoiceChannelProperties> func, RequestOptions options = null) => RestVoiceChannel.ModifyAsync(func, options);
/// <inheritdoc /> public async Task <IReadOnlyCollection <IInviteMetadata> > GetInvitesAsync(RequestOptions options = null) => (await RestVoiceChannel.GetInvitesAsync(options)) .Select(InviteMetadataAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public async Task <ICategoryChannel> GetCategoryAsync(RequestOptions options = null) => (await RestVoiceChannel.GetCategoryAsync(options)) .Abstract();
/// <inheritdoc /> public async Task <IInviteMetadata> CreateInviteAsync(int?maxAge = 86400, int?maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => (await RestVoiceChannel.CreateInviteAsync(maxAge, maxUses, isTemporary, isUnique, options)) .Abstract();
/// <summary> /// Constructs a new <see cref="RestVoiceChannelAbstraction"/> around an existing <see cref="Rest.RestVoiceChannel"/>. /// </summary> /// <param name="restVoiceChannel">The value to use for <see cref="Rest.RestVoiceChannel"/>.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="restVoiceChannel"/>.</exception> public RestVoiceChannelAbstraction(RestVoiceChannel restVoiceChannel) : base(restVoiceChannel) { }