Accessing direct messages?

Hi I am trying to see whenever my bot was DM'ed and then send the dm to myself , the first part I was testing for this was just alerting when a DM wa receieved but for some reason its not working? My code:
const { Client, IntentsBitField, Message, InteractionCollector, DMChannel } = require('discord.js');
require('dotenv').config()


const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
});


client.on('messageCreate', message => {
if (message.channel.type === 1) {
console.log('Dm recieved!');
}
});
const { Client, IntentsBitField, Message, InteractionCollector, DMChannel } = require('discord.js');
require('dotenv').config()


const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
});


client.on('messageCreate', message => {
if (message.channel.type === 1) {
console.log('Dm recieved!');
}
});
5 Replies
d.js toolkit
d.js toolkit2y 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.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
mar
marOP2y ago
How do I implement the partials sorry I'm new to this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
mar
marOP2y ago
Thanks so much its working :))
Want results from more Discord servers?
Add your server