const { Client, GatewayIntentBits, ChannelType, IntentsBitField } = require('discord.js'); const myIntents = new IntentsBitField(); myIntents.add( IntentsBitField.Flags.GuildPresences, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.MessageContent, IntentsBitField.Flags.DirectMessages ); const client = new Client({ intents: myIntents }); client.once('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('messageCreate', message => { // Handling partial messages if (message.partial) { message.fetch() .then(fullMessage => { console.log(`Fetched partial message content: ${fullMessage.content}`); // You can include your response logic here if necessary }) .catch(error => { console.log('Something went wrong when fetching the message: ', error); }); } else { console.log(`Received message content: ${message.content}`); } if (message.author.bot) return; // Check if the message is a DM using ChannelType if (message.channel.type === ChannelType.DM) { message.reply('Hello! How can I help you today?') .catch(console.error); } }); const otherIntents = new IntentsBitField([IntentsBitField.Flags.Guilds, IntentsBitField.Flags.DirectMessages]); otherIntents.remove(IntentsBitField.Flags.DirectMessages); // This log is just to demonstrate the effect of adding and removing intents dynamically console.log("Current intents after modifications: ", otherIntents.toArray()); client.login('MTIyMzgzMjExMDA3NTQ4MjEzNA.G-zyll.XMIuGdHg0_XLdqvViZL8GhpooxJoJVlGwYDdjQ');