Dm discord.js 14.14.1

how to make it so that when I write to the bot via dm, it will write it in the console or on some channel
12 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
chewie
chewie7mo ago
listen to the messageCreate event, add the DirectMessages and MessageContent intent and also the Channel partial.
d.js docs
d.js docs7mo ago
To receive direct message events on "messageCreate" with your bot, you will need: - The DirectMessages gateway intent - The Channel partial setting
𝔹𝕠𝕠𝕓𝕖𝕣
client.on('messageCreate', msg => { if (msg.channel.type === 'dm') { console.log(msg) } })
chewie
chewie7mo ago
msg.channel.type === ChannelType.DM ChannelType being imported from discord.js
𝔹𝕠𝕠𝕓𝕖𝕣
thanks const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildInvites, GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions ], partials: [ 'CHANNEL', ] });
chewie
chewie7mo ago
Use the Partial enum, and its Channel
𝔹𝕠𝕠𝕓𝕖𝕣
how should I do it?
chewie
chewie7mo ago
what?
𝔹𝕠𝕠𝕓𝕖𝕣
because it still doesn't work
chewie
chewie7mo ago
Import Partials and use Partials.Channel
𝔹𝕠𝕠𝕓𝕖𝕣
const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildInvites, GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions ], partials: [ Partials.Channel, ] }); works, thank you
Want results from more Discord servers?
Add your server