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
d.js toolkit
d.js toolkit13mo ago
• 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.
treble/luna
treble/luna13mo ago
show your code + error
ManuelMaccou | Mosaic
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 = { ...
treble/luna
treble/luna13mo ago
and your error? Also, its easier to use codeblocks
ManuelMaccou | Mosaic
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')
d.js docs
d.js docs13mo ago
Codeblocks: ```js const Discord = require("discord.js"); // further code ``` becomes
const Discord = require("discord.js");
// further code
const Discord = require("discord.js");
// further code
Inline Code: `console.log('inline!');` becomes console.log('inline!');
treble/luna
treble/luna13mo ago
your allowedChannels is undefined which means your database method returns undefined
ManuelMaccou | Mosaic
Ah got it. I was using the formatting within discord for the "code block" Wouldnt this define it?
const allowedChannels = await getAllowedChannels();
const allowedChannels = await getAllowedChannels();
I'm a beginner so it might be an obvious "no"
treble/luna
treble/luna13mo ago
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