Issue with dm message event using messageCreate.
I want to log dms but whenever a dm is sent to my bot i get nothing no console log etc. But it works just fine when a msg is sent in a guild.
client.on('messageCreate', async (message) => {
console.log('Received message:', message); // Log the entire message object
if (message.channel.type === ChannelType.DM) {
console.log(`DM from ${message.author.tag}: ${message.content}`);
try {
await message.reply("Hello there! š");
} catch (error) {
console.error('Error replying to DM:', error);
}
} else if (message.channel.type === ChannelType.GUILD_TEXT) {
console.log('Received a message in a guild text channel');
}
console.log(`Channel type: ${message.channel.type}`);
});