Skip to content

Commit

Permalink
fix(Util): fix sorting for GuildChannels (#7002)
Browse files Browse the repository at this point in the history
  • Loading branch information
That-Guy977 committed Dec 1, 2021
1 parent 4fe063f commit c07207f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/util/Util.js
Expand Up @@ -483,11 +483,11 @@ class Util extends null {
* @returns {Collection}
*/
static discordSort(collection) {
const isGuildChannel = collection.first() instanceof GuildChannel;
return collection.sorted(
(a, b) =>
a.rawPosition - b.rawPosition ||
parseInt(b.id.slice(0, -10)) - parseInt(a.id.slice(0, -10)) ||
parseInt(b.id.slice(10)) - parseInt(a.id.slice(10)),
isGuildChannel
? (a, b) => a.rawPosition - b.rawPosition || Number(BigInt(a.id) - BigInt(b.id))
: (a, b) => a.rawPosition - b.rawPosition || Number(BigInt(b.id) - BigInt(a.id)),
);
}

Expand Down Expand Up @@ -616,3 +616,6 @@ class Util extends null {
}

module.exports = Util;

// Fixes Circular
const GuildChannel = require('../structures/GuildChannel');

0 comments on commit c07207f

Please sign in to comment.