/// <summary> /// Adds/edits a permission overwrite to a channel /// </summary> /// <param name="channelId">ID of the channel</param> /// <param name="overwrite">The permission overwrite to add/edit</param> public static DiscordPermissionOverwrite AddPermissionOverwrite(this DiscordClient client, ulong channelId, ulong affectedId, PermissionOverwriteType type, DiscordPermission allow, DiscordPermission deny) { var overwrite = new DiscordPermissionOverwrite() { AffectedId = affectedId, Type = type, Allow = allow, Deny = deny }; client.HttpClient.Put($"/channels/{channelId}/permissions/{overwrite.AffectedId}", overwrite); return(overwrite); }
/// <summary> /// Adds/edits a permission overwrite to a channel /// </summary> /// <param name="overwrite">The permission overwrite to add/edit</param> public void AddPermissionOverwrite(DiscordPermissionOverwrite overwrite) { Client.AddPermissionOverwrite(Id, overwrite); List <DiscordPermissionOverwrite> overwrites = PermissionOverwrites.ToList(); if (overwrites.Where(pe => pe.Id == overwrite.Id).Count() > 0) { overwrites[overwrites.IndexOf(overwrites.First(pe => pe.Id == overwrite.Id))] = overwrite; } else { overwrites.Add(overwrite); } PermissionOverwrites = overwrites; }
/// <summary> /// Adds/edits a permission overwrite to a channel /// </summary> /// <param name="channelId">ID of the channel</param> /// <param name="overwrite">The permission overwrite to add/edit</param> public static void AddPermissionOverwrite(this DiscordClient client, ulong channelId, DiscordPermissionOverwrite overwrite) { client.HttpClient.Put($"/channels/{channelId}/permissions/{overwrite.Id}", overwrite); }