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

219
Vistas
Discordjs DM all server members

I'm trying to DM all server members by a bot trough a command and it only DMs 4 people that are Administrators

message.guild.members.cache.forEach(member => { // Looping through each member of the guild.
    // Trying to send a message to the member.
    // This method might fail because of the member's privacy settings, so we're using .catch

    member.send(`hi`)

    .catch(() => (`Couldn't DM member ${member.user.tag}`));
    message.channel.send(`Success`)

        .catch(console.error);
});
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This operation can be extremely time-consuming. @SuleymanCelik's answer was partially correct because not every user is stored in the bot member cache. To get every single user in the server, you need to make a fetch() call for all the users like this.

guild.members
    .fetch()
    .then(members => members.forEach(member => {
        member
            .send("Hello!")
            .catch(() => {
                console.error(`Failed to send ${member.user.tag} a message`)
            })
    }))
about 4 years ago · Juan Pablo Isaza Denunciar

0

you can send a message to all users whose privacy settings are not turned on in this way

message.guild.members.cache.forEach(member => { // Looping through each member of the guild.
    // Trying to send a message to the member.
    // This method might fail because of the member's privacy settings, so we're using .catch
    member.send("Hello, this is my message!").catch(e => console.error(`Couldn't DM member ${member.user.tag}`));
});
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