-
-
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
Editing of messages fails (Cannot read properties of undefined (reading 'channels')) #10700
Comments
Please include the full error stack to assist in debugging the issue. |
Here you go :)
|
This error suggests that |
I'm fetching it. Look at the code from the initial report. |
The line |
well, it's also not working when I do it like this: try {
if (panelData.action == "edit") {
panel = await panelData.where.edit(messageArgs); // panelData.where is a Message
} else {
panel = await panelData.where.send(messageArgs); // panelData.where is a Text or NewsChannel
}
} I've tested it. |
Also, I've looked through my code and I saw this: /**
*
* @param channelId - The channel ID to fetch
* @param guild - The guild to fetch the channel from
* @param channelTypes - The channel types to validate the channel for
* @returns The channel if it exists and is of the correct type, otherwise `null`
*/
async function getAndValidateChannel(
channelId: string,
guild: Guild,
...channelTypes: ChannelType[]
) {
const _channel = await guild.channels.fetch(channelId);
if (
!(
channelTypes.length
? channelTypes
: [ChannelType.GuildText, ChannelType.GuildAnnouncement]
).includes(_channel.type)
)
return null;
return _channel;
}
// Later
let channel = (await getAndValidateChannel(
parsedLink.channelId,
ctx.guild,
ChannelType.GuildText,
ChannelType.GuildAnnouncement
)) as TextChannel | NewsChannel; Maybe it is because of |
I recommend opening a thread in the support section of our Discord server for further help debugging this. I don't see this as a library bug, as Your error message and stack shows that either I also wouldn't call this a "minimal reproducible code sample" as it includes your own custom validation functions, some of which you chose to omit, and may be impacting the end result. |
Okay, will do tomorrow 👍🏻 |
Which package is this bug report for?
discord.js
Issue description
Cannot read properties of undefined (reading 'channels')
Code sample
Versions
14.17.3
11.0.0
5.2.6
Linux Ubuntu 24.04.1 LTS
Issue priority
Medium (should be fixed soon)
Which partials do you have configured?
Channel
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildWebhooks, GuildMessages, DirectMessages, MessageContent, AutoModerationConfiguration, AutoModerationExecution
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: