-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Channel permissionsFor can be null #5056
Comments
Can someone please explain why channelPermissions can be null? Over the last week or so I'm seeing it return null for the following: if (!discordChannel || !discordChannel.permissionsFor(discordChannel.guild.me).has('SEND_MESSAGES')) { This never happened before the upgrade to v12, but perhaps it's related to something else? |
It is only |
@Extroonie it doesn't seem like either of those things are the issue as the error occurs intermittently. I don't have any code that intentionally deletes from the guild member cache, and if the bot had been kicked from a guild this would happen every time. One of my fellow developers has been able to reproduce this on his local machine several times, but again this is intermittent. I have this code running on startup to resume what we call subscriptions, where a user can subscribe to game updates for a particular channel. We check that the bot still has permission to send messages for a channel that has an active subscription, and remove the subscription if the check fails. I'm apprehensive about using |
@andyearnshaw I wasn't able to reproduce that on version 12.5.1 (latest). Could you please create a reprex? and the fetching approach should just work fine. |
discord.js/src/structures/GuildChannel.js Lines 112 to 117 in 8a7abc9
Null is returned if neither a GuildMember nor a Role instance can be resolved from the provided argument. This would for example be the case if your bot's GuildMember is not cached. (Should that be the case If you have further questions about discord.js usage, please ask them on the discord, this issue was resolved with the linked PR and commit. If you need help with discord.js installation or usage, please go to the discord.js Discord server instead: |
I have created #5260 to make |
I'll work on making sure |
Under normal circunstances, |
Please describe the problem you are having in as much detail as possible:
When using
Channel.permissionsFor
, function can return null but there is no check for that.Include a reproducible code sample here, if possible:
I havn't used permissionsFor directly but used to check
Message.deleted
and received an error.Example here: https://github.com/discordjs/discord.js/blob/master/src/structures/Message.js#L412
Further details:
Relevant client options:
The text was updated successfully, but these errors were encountered: