92 lines
3.1 KiB
JavaScript
92 lines
3.1 KiB
JavaScript
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
|
|
module.exports = {
|
|
category: 'info',
|
|
data: new SlashCommandBuilder()
|
|
.setName('userinfo')
|
|
.setDescription('Affiche les informations d\'un utilisateur.')
|
|
.addUserOption(option =>
|
|
option.setName('user')
|
|
.setDescription('L\'utilisateur dont tu veux voir les informations')
|
|
.setRequired(false)),
|
|
async execute(interaction) {
|
|
const target = interaction.options.getUser('user') || interaction.user;
|
|
const member = await interaction.guild.members.fetch(target.id).catch(() => null);
|
|
|
|
const { colors, emojis } = require('../../utils/constants');
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setAuthor({
|
|
name: `${target.displayName}`,
|
|
iconURL: target.displayAvatarURL({ dynamic: true })
|
|
})
|
|
.setTitle(`${emojis.user} Informations Utilisateur`)
|
|
.setColor(colors.info)
|
|
.setThumbnail(target.displayAvatarURL({ dynamic: true, size: 256 }))
|
|
.addFields(
|
|
{ name: `${emojis.id} ID`, value: `\`${target.id}\``, inline: true },
|
|
{ name: `${emojis.calendar} Compte créé`, value: `<t:${Math.floor(target.createdTimestamp / 1000)}:F>`, inline: true },
|
|
{ name: '🤖 Bot', value: target.bot ? '`Oui`' : '`Non`', inline: true }
|
|
)
|
|
.setFooter({ text: `${interaction.guild.name} • ${interaction.client.user.username}`, iconURL: interaction.client.user.displayAvatarURL() })
|
|
.setTimestamp();
|
|
|
|
if (member) {
|
|
// Récupérer le statut avec gestion des différents cas
|
|
let status = 'Hors ligne';
|
|
let statusEmoji = '⚫';
|
|
|
|
if (member.presence) {
|
|
const presenceStatus = member.presence.status;
|
|
switch (presenceStatus) {
|
|
case 'online':
|
|
status = 'En ligne';
|
|
statusEmoji = '🟢';
|
|
break;
|
|
case 'idle':
|
|
status = 'Inactif';
|
|
statusEmoji = '🟡';
|
|
break;
|
|
case 'dnd':
|
|
status = 'Ne pas déranger';
|
|
statusEmoji = '🔴';
|
|
break;
|
|
case 'invisible':
|
|
status = 'Invisible';
|
|
statusEmoji = '⚫';
|
|
break;
|
|
case 'offline':
|
|
status = 'Hors ligne';
|
|
statusEmoji = '⚫';
|
|
break;
|
|
default:
|
|
status = 'Inconnu';
|
|
statusEmoji = '⚪';
|
|
}
|
|
}
|
|
|
|
embed.addFields(
|
|
{ name: '📥 A rejoint le', value: `<t:${Math.floor(member.joinedTimestamp / 1000)}:F>`, inline: true },
|
|
{ name: '⏰ Statut', value: `${statusEmoji} \`${status}\``, inline: true },
|
|
{ name: '👑 Rôle le plus élevé', value: member.roles.highest.toString(), inline: true },
|
|
{ name: '🎭 Rôles', value: member.roles.cache.size > 1 ? member.roles.cache.filter(r => r.id !== interaction.guild.id).map(r => r.toString()).slice(0, 10).join(', ') || '`Aucun`' : '`Aucun`', inline: false }
|
|
);
|
|
|
|
if (member.nickname) {
|
|
embed.addFields({ name: '📝 Surnom', value: `\`${member.nickname}\``, inline: true });
|
|
}
|
|
|
|
if (member.roles.cache.size > 11) {
|
|
embed.addFields({ name: '📊 Total de rôles', value: `\`${member.roles.cache.size - 1}\``, inline: true });
|
|
}
|
|
}
|
|
|
|
if (target.banner) {
|
|
embed.setImage(target.bannerURL({ dynamic: true, size: 1024 }));
|
|
}
|
|
|
|
await interaction.reply({ embeds: [embed] });
|
|
},
|
|
};
|
|
|