Message doesn't send to channel

client.on(Events.GuildMemberAdd, async (member) => {
    if (member.guild.id != GUILD_ID) return;

    // Read the JSON file
    const jsonData = JSON.parse(readFileSync(join(__dirname, 'messages.json'), 'utf8'));

    // Get a random join message index
    const randomIndex = Math.floor(Math.random() * jsonData.joinMessages.length);

    // Get the random join message
    const randomJoinMessage = jsonData.joinMessages[randomIndex];

    console.log(randomJoinMessage);

    // Insert the user's username into the join message
    const formattedJoinMessage = randomJoinMessage.replace("{userName}", member.user.username);
    
    console.log(formattedJoinMessage);

    const channel = client.channels.cache.get('1174309146816950303'); // #new-beavers
    if (channel && channel.type == ChannelType.GuildText) {
        channel.send(formattedJoinMessage);
        console.log ("message sent");
    }
});

basically, all the log messages appear EXCEPT for message sent, and the message is not sent to the channel. the channel id is correct
Was this page helpful?