@Override public int compareTo(TextChannel chan) { if (this == chan) return 0; if (this.getGuild() != chan.getGuild()) throw new IllegalArgumentException( "Cannot compare TextChannels that aren't from the same guild!"); if (this.getPositionRaw() != chan.getPositionRaw()) return chan.getPositionRaw() - this.getPositionRaw(); OffsetDateTime thisTime = MiscUtil.getCreationTime(this); OffsetDateTime chanTime = MiscUtil.getCreationTime(chan); // We compare the provided channel's time to this's time instead of the reverse as one would // expect due to how // discord deals with hierarchy. The more recent a channel was created, the lower its hierarchy // ranking when // it shares the same position as another channel. return chanTime.compareTo(thisTime); }
@Override public boolean equals(Object o) { if (!(o instanceof TextChannel)) return false; TextChannel oTChannel = (TextChannel) o; return this == oTChannel || this.getId().equals(oTChannel.getId()); }