From a05ba9337646cc7088ec3948349852eaf3325c16 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Mon, 11 Sep 2023 03:56:46 +0200 Subject: [PATCH] fix high low --- DisCatSharp/Entities/Channel/DiscordChannel.cs | 3 +++ DisCatSharp/Entities/Guild/DiscordRole.cs | 3 +++ DisCatSharp/Entities/PositionalSnowflakeObject.cs | 10 ++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DisCatSharp/Entities/Channel/DiscordChannel.cs b/DisCatSharp/Entities/Channel/DiscordChannel.cs index c7e617d82a..be4fa36677 100644 --- a/DisCatSharp/Entities/Channel/DiscordChannel.cs +++ b/DisCatSharp/Entities/Channel/DiscordChannel.cs @@ -87,6 +87,9 @@ public DiscordChannel? Parent [JsonProperty("template", NullValueHandling = NullValueHandling.Ignore)] public string? Template { get; internal set; } + /// + internal override bool HighIsLow { get; set; } = true; + /// /// Gets the flags of this channel. /// diff --git a/DisCatSharp/Entities/Guild/DiscordRole.cs b/DisCatSharp/Entities/Guild/DiscordRole.cs index 2acb52ed28..b2354de2d8 100644 --- a/DisCatSharp/Entities/Guild/DiscordRole.cs +++ b/DisCatSharp/Entities/Guild/DiscordRole.cs @@ -59,6 +59,9 @@ public class DiscordRole : PositionalSnowflakeObject, IEquatable [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] public string? Description { get; internal set; } + /// + internal override bool HighIsLow { get; set; } = false; + /// /// Gets the color of this role. /// diff --git a/DisCatSharp/Entities/PositionalSnowflakeObject.cs b/DisCatSharp/Entities/PositionalSnowflakeObject.cs index 69da6cf12c..7640fbf33e 100644 --- a/DisCatSharp/Entities/PositionalSnowflakeObject.cs +++ b/DisCatSharp/Entities/PositionalSnowflakeObject.cs @@ -37,6 +37,12 @@ public abstract class PositionalSnowflakeObject : SnowflakeObject [JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)] public int Position { get; internal set; } + /// + /// High position value equals a lower position. + /// + [JsonIgnore] + internal virtual bool HighIsLow { get; set; } + /// /// Initializes a new instance of the class. /// @@ -52,7 +58,7 @@ internal PositionalSnowflakeObject(List? ignored = null) /// The second . /// if the left one is higher positioned; otherwise, . public static bool operator >(PositionalSnowflakeObject? left, PositionalSnowflakeObject? right) - => left is not null && right is not null && left.Position < right.Position; + => left is not null && right is not null && (left.HighIsLow ? left.Position < right.Position : left.Position > right.Position); /// /// Determines whether the left is lower positioned than the right . @@ -61,7 +67,7 @@ internal PositionalSnowflakeObject(List? ignored = null) /// The second . /// if the left one is lower positioned; otherwise, . public static bool operator <(PositionalSnowflakeObject? left, PositionalSnowflakeObject? right) - => left is not null && right is not null && left.Position > right.Position; + => left is not null && right is not null && (left.HighIsLow ? left.Position > right.Position : left.Position < right.Position); /// /// Returns a which represents the .