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

156
Vistas
Checking if a message was sent from a DM not working

I am using Discord.js v12 and trying to check if a message was sent from a DM but it doesn't work for me, I have tried this method:

  if (msg.channel.type === 'dm')

This was working fine couple months ago but it doesn't work anymore. When i try console.log(msg.channel.type) it only returns text and doesn't return dm when the bot gets an DM and I can't find any solutions for this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Are you sure you haven't updated your discord.js version and you're still using v12?

Channel types in v13 are now uppercase and align with Discord's naming conventions. See below the changes:

channel type v12 v13
DM channel dm DM
group DM channel N/A GROUP_DM
guild text channel text GUILD_TEXT
guild text channel's public thread channel N/A GUILD_PUBLIC_THREAD
guild text channel's private thread channel N/A GUILD_PRIVATE_THREAD
guild voice channel voice GUILD_VOICE
guild stage voice channel N/A GUILD_STAGE_VOICE
guild category channel category GUILD_CATEGORY
guild news channel news GUILD_NEWS
guild news channel's public thread channel N/A GUILD_NEWS_THREAD
guild store channel store GUILD_STORE
generic channel of unknown type unknown UNKNOWN

It means, that if you want to check if the channel's type is DM, you need to use:

if (msg.channel.type === 'DM')
about 4 years ago · Juan Pablo Isaza 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