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

286
Vistas
DiscordAPIError: Cannot send messages to this user at RequestHandler.execute

Hey so i made a 'hack' command in my bot as a joke, i want it to dm the author of the message, but whenever i run the command, it just gives me a error, even if the author has open dm's. this is the error:

DiscordAPIError: Cannot send messages to this user

And this is my code:

msg.author.send(`Name:${taggedUser.username},
             ID:${taggedUser.id}
             IP Address:${response}`).catch(console.error)

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

0

It is not possible for this particular error to originate apart from the member being either unavailable to the client or has direct messages closed you can simply tweak your code a little so if the dms are closed it would post to the channel instead like so:

msg.author.send(`Name:${taggedUser.username},
             ID:${taggedUser.id}
             IP Address:${response}`).catch(() => {
    msg.channel.send(`Unable to Direct Message user instead sending this here!\n\n Name:${taggedUser.username},
             ID:${taggedUser.id}
             IP Address:${response}`)
    });

Sources:

  • Discord.js' Role:
    discordjs/discord.js/src/rest/DiscordAPIError.js
    This just extends the error thrown by discord API in case of explicit faliure so has no hand in the error.
  • Discord's Role:
    Documentation reference of error messages
    This throws the specific error and you know, Discord itself can't be wrong or else stackoverflow would be flooded with similar questions and bots would break haha!
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