Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
How can I make a Discord bot listen to my DMs instead of simple channel messages?

I'm messing around creating a simple quiz bot. So far it is working well in channels, but I would like to modify it into a DM-only quiz bot.

I listen to commands from Discord users like this:

client.on('messageCreate', async message => {

And it works well but ONLY IN channels, not in DMs.

I've searched for 'directMessageCreate' or anything else but I haven't found the solution yet.

I also tried to search for tutorials and everybody starts the bot DM with a public command in a public channel, I would like to make a DM only bot.

How could I make my public bot a DM only bot?

E D I T:

These are my intents, which have DIRECT_MESSAGES listed on. Is something still missing?

const client = new discord.Client({
    intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES"]
});
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You'll need to enable the required intents and partials to be able to listen to direct messages. As you've already added DIRECT_MESSAGES, you must have missed the CHANNEL partial. It's required for DMs. Although server channels will always be available, DM channels can be uncached and that's why you'll need to add it like this:

const client = new discord.Client({
    intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES"],
    partials: ['CHANNEL']
});

If you want to make a DM only bot, you'll need to check the channel.type and ignore anything that's not a DM:

client.on('messageCreate', (message) => {
    if (message.author.bot || message.channel.type !== 'DM') return;

    // handle the command sent in a DM
});

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda