Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Role): calculate position correctly when rawPositions are equal #9872

Merged
merged 1 commit into from Oct 9, 2023

Conversation

vladfrangu
Copy link
Member

@vladfrangu vladfrangu commented Oct 3, 2023

Diplopia of #9871

Please describe the changes this PR makes and why it should be merged:

Positions were not calculated right if a guild had raw positions equal across roles

This happened due to not noticing the previous sorting behavior which was (cleaned up from old v13)

function discordSort(collection) {
  return collection.sorted(
    (a, b) => a.rawPosition - b.rawPosition || Number(BigInt(b.id) - BigInt(a.id)),
  );
}

Peep the order: b.id - a.id. In current code, it's equivalent to a.id - b.id

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@vercel
Copy link

vercel bot commented Oct 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Oct 3, 2023 9:44pm
discord-js-guide ⬜️ Ignored (Inspect) Oct 3, 2023 9:44pm

@kodiakhq kodiakhq bot merged commit 56b481b into v13 Oct 9, 2023
13 checks passed
@kodiakhq kodiakhq bot deleted the fix/v13/role-position-calculation branch October 9, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants