Skip to content

Conversation

@KubaZ2
Copy link
Member

@KubaZ2 KubaZ2 commented Jan 29, 2026

Move all role position comparison logic from Role to a new RolePosition struct, including comparison operators and methods. Update Role to expose a Position property of type RolePosition and remove IComparable implementation. Refactor all usages and tests to use RolePosition for ordering and equality checks. Improve code clarity and maintainability by centralizing comparison logic.

Move all role position comparison logic from Role to a new RolePosition struct, including comparison operators and methods. Update Role to expose a Position property of type RolePosition and remove IComparable<Role> implementation. Refactor all usages and tests to use RolePosition for ordering and equality checks. Improve code clarity and maintainability by centralizing comparison logic.
@github-actions
Copy link

The documentation preview is available at https://preview.netcord.dev/253.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors role comparison logic by extracting it from the Role class into a new RolePosition struct. The Role class now exposes a Position property of type RolePosition and no longer implements IComparable<Role>. All comparison operations and tests have been updated to use the new RolePosition type.

Changes:

  • Introduced RolePosition struct with comparison operators and IComparable<RolePosition>, IEquatable<RolePosition> implementations
  • Updated Role class to expose Position property of type RolePosition and renamed the raw position to RawPosition
  • Updated all role ordering operations to use OrderByDescending(r => r.Position) instead of OrderDescending()
  • Refactored role comparison tests to use RolePosition comparisons

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
NetCord/Role.cs Removed IComparable<Role> implementation from Role, added RolePosition struct with all comparison logic, and exposed Position property
Tests/RoleTest/RoleComparison.cs Updated all test assertions to compare role.Position instead of role directly
Tests/NetCord.Test/Commands/NormalCommands.cs Changed role ordering from OrderDescending() to OrderByDescending(r => r.Position)
NetCord/Rest/RestGuild.cs Updated role comparison logic to use RolePosition for finding highest position and comparisons
Documentation/guides/services/CustomModuleBasesAndContexts/CustomModuleBases/CustomCommandModule.cs Updated role ordering from OrderDescending() to OrderByDescending(r => r.Position)
Comments suppressed due to low confidence (1)

NetCord/Rest/RestGuild.cs:73

        foreach (var role in y.GetRoles(this))
        {
            var comparisonResult = xHighestPosition.CompareTo(role.Position);

            if (comparisonResult < 0)
                return -1;

            result = Math.Min(result, comparisonResult);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

NetCord/Rest/RestGuild.cs:73

        foreach (var role in y.GetRoles(this))
        {
            var comparisonResult = xHighestPosition.CompareTo(role.Position);

            if (comparisonResult < 0)
                return -1;

            result = Math.Min(result, comparisonResult);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KubaZ2 KubaZ2 merged commit 557202c into alpha Jan 29, 2026
7 checks passed
@KubaZ2 KubaZ2 deleted the feature/useful-role-position branch January 29, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants