#Can't send message to specific channels

1 messages · Page 1 of 1 (latest)

steady portal

In my ClientReady event. I can send a message to specific channel

const notiChannel = client.channels.cache.get('1379862671217791069');

notiChannel.send({ 
    embeds: [notiEmbed]
});

but it seems not to work with this slash command

const notiChannel = client.channels.cache.get('1379778222169784431');
const publicNotiChannel = client.channels.cache.get('1374718357953183804');

try {
    const notificationEmbed = new EmbedBuilder()
    // ...

    if (notiChannel) {
        await notiChannel.send({ embeds: [notificationEmbed] });
    }
                            
    if (publicNotiChannel) {
        const publicMessage = await publicNotiChannel.send({ embeds: [notificationEmbed] });
        await publicMessage.react('👋🏻');
    }
} catch (error) {
    console.error('Error : '+ error.message);
}

it throws: Cannot read properties of undefined (reading 'channels')