public static async Task <Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client, Action <ModifyGuildChannelParams> func, RequestOptions options) { var args = new ModifyGuildChannelParams(); func(args); return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false)); }
/// <exception cref="InvalidOperationException">This channel does not have a parent channel.</exception> public static async Task SyncPermissionsAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options) { var category = await GetCategoryAsync(channel, client, options).ConfigureAwait(false); if (category == null) throw new InvalidOperationException("This channel does not have a parent channel."); var apiArgs = new ModifyGuildChannelParams { Overwrites = category.PermissionOverwrites .Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue, Deny = overwrite.Permissions.DenyValue }).ToArray() }; await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); }
public async Task ModifyAsync(Action <ModifyGuildChannelParams> func) { if (func == null) { throw new NullReferenceException(nameof(func)); } var args = new ModifyGuildChannelParams(); func(args); if (!args._name.IsSpecified) { args._name = Name; } var model = await Discord.ApiClient.ModifyGuildChannelAsync(Id, args).ConfigureAwait(false); Update(model, UpdateSource.Rest); }