diff --git a/DisCatSharp/Entities/Channel/Overwrite/DiscordOverwriteBuilder.cs b/DisCatSharp/Entities/Channel/Overwrite/DiscordOverwriteBuilder.cs index f3ab04ca2..765b0379f 100644 --- a/DisCatSharp/Entities/Channel/Overwrite/DiscordOverwriteBuilder.cs +++ b/DisCatSharp/Entities/Channel/Overwrite/DiscordOverwriteBuilder.cs @@ -1,180 +1,180 @@ // This file is part of the DisCatSharp project, based off DSharpPlus. // // Copyright (c) 2021-2022 AITSYS // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. using System.Threading.Tasks; using DisCatSharp.Enums; using Newtonsoft.Json; namespace DisCatSharp.Entities; /// /// Represents a Discord permission overwrite builder. /// public sealed class DiscordOverwriteBuilder { /// /// Gets or sets the allowed permissions for this overwrite. /// public Permissions Allowed { get; set; } /// /// Gets or sets the denied permissions for this overwrite. /// public Permissions Denied { get; set; } /// - /// Gets the type of this overwrite's target. + /// Gets or sets the type of this overwrite's target. /// - public OverwriteType Type { get; private set; } + public OverwriteType Type { get; set; } /// - /// Gets the target for this overwrite. + /// Gets or sets the target for this overwrite. /// - public SnowflakeObject Target { get; private set; } + public SnowflakeObject Target { get; set; } /// /// Creates a new Discord permission overwrite builder for a member. This class can be used to construct permission overwrites for guild channels, used when creating channels. /// public DiscordOverwriteBuilder(DiscordMember member) { this.Target = member; this.Type = OverwriteType.Member; } /// /// Creates a new Discord permission overwrite builder for a role. This class can be used to construct permission overwrites for guild channels, used when creating channels. /// public DiscordOverwriteBuilder(DiscordRole role) { this.Target = role; this.Type = OverwriteType.Role; } /// /// Creates a new Discord permission overwrite builder. This class can be used to construct permission overwrites for guild channels, used when creating channels. /// public DiscordOverwriteBuilder() { } /// /// Allows a permission for this overwrite. /// /// Permission or permission set to allow for this overwrite. /// This builder. public DiscordOverwriteBuilder Allow(Permissions permission) { this.Allowed |= permission; return this; } /// /// Denies a permission for this overwrite. /// /// Permission or permission set to deny for this overwrite. /// This builder. public DiscordOverwriteBuilder Deny(Permissions permission) { this.Denied |= permission; return this; } /// /// Sets the member to which this overwrite applies. /// /// Member to which apply this overwrite's permissions. /// This builder. public DiscordOverwriteBuilder For(DiscordMember member) { this.Target = member; this.Type = OverwriteType.Member; return this; } /// /// Sets the role to which this overwrite applies. /// /// Role to which apply this overwrite's permissions. /// This builder. public DiscordOverwriteBuilder For(DiscordRole role) { this.Target = role; this.Type = OverwriteType.Role; return this; } /// /// Populates this builder with data from another overwrite object. /// /// Overwrite from which data will be used. /// This builder. public async Task FromAsync(DiscordOverwrite other) { this.Allowed = other.Allowed; this.Denied = other.Denied; this.Type = other.Type; this.Target = this.Type == OverwriteType.Member ? await other.GetMemberAsync().ConfigureAwait(false) as SnowflakeObject : await other.GetRoleAsync().ConfigureAwait(false) as SnowflakeObject; return this; } /// /// Builds this DiscordOverwrite. /// /// Use this object for creation of new overwrites. internal DiscordRestOverwrite Build() => new() { Allow = this.Allowed, Deny = this.Denied, Id = this.Target.Id, Type = this.Type, }; } internal struct DiscordRestOverwrite { /// /// Determines what is allowed. /// [JsonProperty("allow", NullValueHandling = NullValueHandling.Ignore)] internal Permissions Allow { get; set; } /// /// Determines what is denied. /// [JsonProperty("deny", NullValueHandling = NullValueHandling.Ignore)] internal Permissions Deny { get; set; } /// /// Gets or sets the id. /// [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] internal ulong Id { get; set; } /// /// Gets or sets the overwrite type. /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] internal OverwriteType Type { get; set; } }