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(GuildChannel): Fix manageable method for voice-channels #6447
fix(GuildChannel): Fix manageable method for voice-channels #6447
Conversation
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This is incorrect, you can manage channels without permission to view them, the error in the original issue is caused because the bot did not have permission to view the channel, and thus could not change other roles permission on it. |
So you can manage voice-channel without view permission but for text channels, it is needed? |
Correct, I should have specified voice, but the permission bit to manage the channel is actually |
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.
Can't we just do this?
// Owner always can manage:
if (this.client.user.id === this.guild.ownerId) return true;
// Get the permissions, if we couldn't resolve to a member, return false:
const permissions = this.permissionsFor(this.client.user);
if (!permissions) return false;
// Get the bitfield and see if we fulfill it:
const bitfield = VoiceBasedChannelTypes.includes(this.type)
? Permissions.FLAGS.VIEW_CHANNEL | Permissions.FLAGS.MANAGE_CHANNELS | Permissions.FLAGS.CONNECT
: Permissions.FLAGS.VIEW_CHANNEL | Permissions.FLAGS.MANAGE_CHANNELS;
return permissions.has(bitfield, false);
It's far more efficient, resolves MemberResolvable
and creates a Permissions
instance only once (as opposed to twice).
Are we moving forward with kyras suggestion here, or whats the plan @DraftProducts |
We can go with Kyras suggestion 👍 |
Co-authored-by: Kyra <kyranet@users.noreply.github.com>
Co-authored-by: ckohen <chaikohen@gmail.com>
Please describe the changes this PR makes and why it should be merged:
Resolves #6446
<GuildChannel>.manageable
is not efficient with voice channels because<GuildChannel>.viewable
is not checked on voice channels.Status and versioning classification: