/// <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)); }
public static async Task <Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client, Action <GuildChannelProperties> func, RequestOptions options) { var args = new GuildChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyGuildChannelParams { Name = args.Name, Position = args.Position, CategoryId = args.CategoryId, Overwrites = args.PermissionOverwrites.IsSpecified ? args.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[]>(), }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
public static async Task <Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client, Action <GuildChannelProperties> func, RequestOptions options) { var args = new GuildChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyGuildChannelParams { Name = args.Name, Position = args.Position }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
/// <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 }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestCategoryChannel.Create(client, guild, model)); }