@@ -5,6 +5,7 @@ const { Error } = require('../errors');
|
||||
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
||||
const { VoiceBasedChannelTypes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Represents a guild channel from any of the following:
|
||||
@@ -145,8 +146,21 @@ class GuildChannel extends Channel {
|
||||
* @readonly
|
||||
*/
|
||||
get position() {
|
||||
const sorted = this.guild._sortedChannels(this);
|
||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
||||
const selfIsCategory = this.type === 'GUILD_CATEGORY';
|
||||
const types = Util.getSortableGroupTypes(this.type);
|
||||
|
||||
let count = 0;
|
||||
for (const channel of this.guild.channels.cache.values()) {
|
||||
if (!types.includes(channel.type)) continue;
|
||||
if (!selfIsCategory && channel.parentId !== this.parentId) continue;
|
||||
if (this.rawPosition === channel.rawPosition) {
|
||||
if (BigInt(channel.id) < BigInt(this.id)) count++;
|
||||
} else if (this.rawPosition > channel.rawPosition) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -228,8 +228,13 @@ class Role extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get position() {
|
||||
const sorted = this.guild._sortedRoles();
|
||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
||||
let count = 0;
|
||||
for (const role of this.guild.roles.cache.values()) {
|
||||
if (this.rawPosition > role.rawPosition) count++;
|
||||
else if (this.rawPosition === role.rawPosition && BigInt(this.id) > BigInt(role.id)) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user