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

module.exports.run = (client, message, args) => {
    const guild = message.guild;

    message.guild.members.fetch().then(fetchAll => {

    const embed = new MessageEmbed()
    .setColor("#0c2461")
    .setThumbnail(guild.iconURL())
    .addField(`Plus d'informations à propos du serveur : **${guild.name}**`,
        `•  ID: ${guild.id}
        • Owner: ${guild.owner.user.tag} (${guild.ownerID})
        • Roles: ${guild.roles.cache.size}
        • Créé le: ${moment(guild.createdAt).format('DD/MM/YYYY')}
        `
    )


    const embed2 = new MessageEmbed()
    .setColor("#0c2461")
    .setDescription("Statistique du serveur : ")
    .addFields(
        { name: `Nombre de membres total : `, value: `${guild.memberCount -1 }`},
        { name: `Nombre de salons textuels : `, value: `${guild.channels.cache.filter(ch => ch.type === "text").size}`},
        { name: `Nombre de salons vocaux : `, value: `${guild.channels.cache.filter(ch => ch.type === "voice").size}`},
        { name: 'Membres Totaux', value: `${fetchAll.size}`, inline: true},
    )
    .setTimestamp();

    message.channel.send(embed);
    message.channel.send(embed2);

    });
};

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