message.channel.parent undefined in forum channel?
I'm getting an error where message.channel.parent is undefined. My intention is to cross-check the forum channel in which a user posts to make sure it's an "allowed channel". Am I not using this correctly to identify the parent forum channel of a new thread?
9 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.show your code + error
async function getAllowedChannels() {
try {
const { data: allowedChannels, error } = await supabase
.from('allowed_channels')
.select('channel_id, webhook_id, guild_id');
if (error) {
throw error;
}
return allowedChannels;
} catch (error) {
handleError('Error fetching allowed channels:' + error.message);
return [];
}
}
const allowedChannels = await getAllowedChannels();
if (allowedChannels.some(channel => channel.channel_id === message.channel.parent.id)) {
const messageData = { ...
and your error? Also, its easier to use codeblocks
I did use code blocks...or at least I meant to. It showing as a block on my end
Uncaught Exception: TypeError: Cannot read properties of undefined (reading 'some')
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
Inline Code:
`console.log('inline!');` becomes
console.log('inline!');
your allowedChannels is undefined
which means your database method returns undefined
Ah got it. I was using the formatting within discord for the "code block"
Wouldnt this define it?
I'm a beginner so it might be an obvious "no"
yes, if your allowedchannels actually were to return something else than 'undefined'
your method might be working, but your database just doesnt return any data because it cannot find it or something