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

module.exports.run = (client, message, args) => {
    let member = message.member;
    if (args[0]) member = message.guild.member(message.mentions.users.first());
    let user = member.user;

    const embed = new MessageEmbed()
        .setColor("#0c2461")
        .setThumbnail(user.displayAvatarURL())
        .addField(`Plus d'informations à propos de **${user.username}**`,
            `• Nom: ${user.tag}
            • Bot: ${user.bot ? 'true' : 'false'}
            • Crée le: ${moment(user.createdAt).format('DD/MM/YYYY | hh:mm')}
            • Statut: ${user.presence.status.toUpperCase()}`
        );

    const embed2 = new MessageEmbed()
        .setColor("#0c2461")
        .addField(`L'utilisateur **${user.username}** ${member.username === undefined ? '' : `aka **${member.username}**`}`,
            `• A rejoint le serveur le: ${moment(member.joinedAt).format('DD/MM/YYYY | hh:mm')}
            • Ce membre possède les rôles suivants : ${member.roles.cache.map(roles => `\`${roles.name}\``).join(', ')}`
        );

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

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