Skip to content

Commit

Permalink
Fix filterHidden in GuildImpl#getChannels (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
MineKing9534 committed Jun 8, 2022
1 parent 4f7b413 commit f54e392
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -719,7 +719,7 @@ public List<GuildChannel> getChannels(boolean includeHidden)
Predicate<GuildChannel> filterHidden = it -> {
//TODO-v5: Do we need to if-protected cast here? If the channel _isnt_ a IPermissionContainer, then would we even be using this filter on it?
if (it instanceof IPermissionContainer) {
self.hasPermission((IPermissionContainer) it, Permission.VIEW_CHANNEL);
return self.hasPermission((IPermissionContainer) it, Permission.VIEW_CHANNEL);
}
return false;
};
Expand Down

4 comments on commit f54e392

@DxsSucuk
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibility to change the return statement into one, instead of using an if statement to then later cast and check it? This would merge both statement as example return it instanceof IPermissionContainer && self.hasPermission((IPermissionContainer) it, Permission.VIEW_CHANNEL)

@Tais993
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks ugly imho, this is more readable

And uh, no-one will see this comment

@DxsSucuk
Copy link
Contributor

@DxsSucuk DxsSucuk commented on f54e392 Jun 13, 2022

Choose a reason for hiding this comment

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

Really? In my opinion it would look better if it would be like this.

return it instanceof IPermissionContainer &&
              self.hasPermission((IPermissionContainer)it, Permission.VIEW_CHANNEL)

@Tais993
Copy link
Contributor

Choose a reason for hiding this comment

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

ah my bad I was idiotic, I guess looks fine, have no preference over either

Please sign in to comment.