-
-
Notifications
You must be signed in to change notification settings - Fork 737
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
Conversation
@@ -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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Just a reminder that now this PR depends on #952 |
* 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
Probably forgotten when copied from another file.