const { MESSAGES } = require("../../util/constants");
const { MessageEmbed } = require ("discord.js");

module.exports.run = (client, message, args) => {
    const nameGuild = message.guild.name;
    message.guild.members.fetch().then(fetchAll => {
        const offline = fetchAll.filter(m => m.presence.status === 'offline');
        const dnd = fetchAll.filter(m => m.presence.status === 'dnd');
        const online = fetchAll.filter(m => m.presence.status === 'online');
        const bot = message.guild.members.cache.filter(member => member.user.bot).size; 
        
        const embed = new MessageEmbed()
        .setTitle("Informations sur les membres du serveur !")
        .setColor("#0c2461")
        .addFields(
            { name: 'Nom du serveur', value: `${nameGuild}`, inline: true},
            { name: 'Membres Totaux', value: `${fetchAll.size}`, inline: true},
            { name: 'Nombre de Bots', value: `${bot}`, inline: true},
            { name: 'Membres Connectés', value: `${online.size}`, inline: true},
            { name: 'Membres Hors-ligne', value: `${offline.size}`, inline: true},
            { name: 'Membres Occupés', value: `${dnd.size}`, inline: true},
        )
        .setTimestamp();

    message.channel.send(embed);

    });
};

module.exports.help = MESSAGES.COMMANDS.INFORMATIONS.STATS;