Discordjs DM all server members

I’m trying to DM all server members by a bot trough a command and it … Read more 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);
    });

Source: JavaSript – Stack Overflow


Categories: NewsTags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *