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 SocketCategoryChannel properties #945

Merged
merged 5 commits into from Mar 24, 2018
Merged

Fix SocketCategoryChannel properties #945

merged 5 commits into from Mar 24, 2018

Conversation

SubZero0
Copy link
Member

Probably forgotten when copied from another file.

@@ -15,7 +15,7 @@ namespace Discord.WebSocket
public class SocketCategoryChannel : SocketGuildChannel, ICategoryChannel
{
public override IReadOnlyCollection<SocketGuildUser> Users
=> Guild.Users.Where(x => x.VoiceChannel?.Id == Id).ToImmutableArray();
=> throw new NotSupportedException();
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to use something like SocketTextChannels.Users, and resolve the permissions instead of throwing an exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, makes sense. I'll update it.

Copy link
Member Author

Choose a reason for hiding this comment

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

As talked in the dev guild, resolving the permissions could be misleading, since if the users don't have read access to any channels inside, they won't be able to see the category too.

A suggestion would be Guild.Channels.Where(x => x.CategoryId == Id).SelectMany(x => x.Users).Distinct().ToImmutableArray(); that would list all users that can see at least one channel (and the category consequently) but doesn't mean all of them can see all the channels inside it.

Copy link
Member

Choose a reason for hiding this comment

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

That seems fine to me.

CategoryId is the category that "owns" this channel. That is actually impossible right now for category channels, so it returns null and get all channels wrongly.
@SubZero0 SubZero0 changed the title Update Users property for category channels Fix SocketCategoryChannel properties Jan 30, 2018
@SubZero0
Copy link
Member Author

Just a reminder that now this PR depends on #952

@foxbot foxbot merged commit 810f6d6 into discord-net:dev Mar 24, 2018
FiniteReality pushed a commit to FiniteReality/Discord.Net that referenced this pull request May 5, 2018
* Update Users property for category channels

* Wrong property being used for Channels property

CategoryId is the category that "owns" this channel. That is actually impossible right now for category channels, so it returns null and get all channels wrongly.

* Resolve permissions for category

* Remove spaces

* Small fix for IChannel.GetUsersAsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants