Skip to content

Commit

Permalink
fix high low
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Sep 11, 2023
1 parent 3c7de4c commit a05ba93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions DisCatSharp/Entities/Channel/DiscordChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public DiscordChannel? Parent
[JsonProperty("template", NullValueHandling = NullValueHandling.Ignore)]
public string? Template { get; internal set; }

/// <inheritdoc />
internal override bool HighIsLow { get; set; } = true;

/// <summary>
/// Gets the flags of this channel.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions DisCatSharp/Entities/Guild/DiscordRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class DiscordRole : PositionalSnowflakeObject, IEquatable<DiscordRole>
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string? Description { get; internal set; }

/// <inheritdoc />
internal override bool HighIsLow { get; set; } = false;

/// <summary>
/// Gets the color of this role.
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions DisCatSharp/Entities/PositionalSnowflakeObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public abstract class PositionalSnowflakeObject : SnowflakeObject
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int Position { get; internal set; }

/// <summary>
/// High position value equals a lower position.
/// </summary>
[JsonIgnore]
internal virtual bool HighIsLow { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="PositionalSnowflakeObject"/> class.
/// </summary>
Expand All @@ -52,7 +58,7 @@ internal PositionalSnowflakeObject(List<string>? ignored = null)
/// <param name="right">The second <see cref="PositionalSnowflakeObject"/>.</param>
/// <returns><see langword="true"/> if the left one is higher positioned; otherwise, <see langword="false"/>.</returns>
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);

/// <summary>
/// Determines whether the left <see cref="PositionalSnowflakeObject"/> is lower positioned than the right <see cref="PositionalSnowflakeObject"/>.
Expand All @@ -61,7 +67,7 @@ internal PositionalSnowflakeObject(List<string>? ignored = null)
/// <param name="right">The second <see cref="PositionalSnowflakeObject"/>.</param>
/// <returns><see langword="true"/> if the left one is lower positioned; otherwise, <see langword="false"/>.</returns>
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);

/// <summary>
/// Returns a <see langword="string"/> which represents the <see cref="PositionalSnowflakeObject"/>.
Expand Down

0 comments on commit a05ba93

Please sign in to comment.