nice
This commit is contained in:
parent
e2e2daa710
commit
0bd3408c8e
@ -36,19 +36,12 @@ module.exports = {
|
||||
const user = await interaction.client.users.fetch(link.discord_id).catch(() => null);
|
||||
const discordName = user ? (user.globalName ? user.globalName : user.username) : link.discord_username;
|
||||
const discordMention = `<@${link.discord_id}>`;
|
||||
const lastConn = link.lastConnection
|
||||
? `📅 Dernière connexion: <t:${Math.floor(new Date(link.lastConnection).getTime() / 1000)}:R>`
|
||||
: '📅 Dernière connexion: Jamais vu';
|
||||
|
||||
embed.addFields({
|
||||
name: `👤 ${discordName}`,
|
||||
value: `${discordMention}
|
||||
🎮 Palworld: **${link.palworld_username}**
|
||||
🆔 Steam ID: \`${link.steam_id}\`
|
||||
🎯 Player ID: \`${link.player_id || 'N/A'}\`
|
||||
${lastConn}
|
||||
📅 Lié le: ${new Date(link.linked_at).toLocaleDateString('fr-FR')}`,
|
||||
inline: false
|
||||
🎮 Palworld: **${link.palworld_username}**`,
|
||||
inline: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
71
commands/utility/info.js
Normal file
71
commands/utility/info.js
Normal file
@ -0,0 +1,71 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder, MessageFlags } = require('discord.js');
|
||||
const { getUserLink } = require('../../database.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('info')
|
||||
.setDescription('Afficher les informations détaillées d\'un compte lié')
|
||||
.addUserOption(option =>
|
||||
option.setName('utilisateur')
|
||||
.setDescription('L\'utilisateur Discord dont vous voulez voir les informations')
|
||||
.setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
try {
|
||||
await interaction.deferReply({});
|
||||
|
||||
const targetUser = interaction.options.getUser('utilisateur');
|
||||
const link = await getUserLink(targetUser.id);
|
||||
|
||||
if (!link) {
|
||||
return interaction.editReply({
|
||||
content: `❌ Aucun compte lié trouvé pour ${targetUser.globalName || targetUser.username}.`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
|
||||
const lastConn = link.lastConnection
|
||||
? `<t:${Math.floor(new Date(link.lastConnection).getTime() / 1000)}:R>`
|
||||
: 'Jamais vu';
|
||||
|
||||
const linkedDate = `<t:${Math.floor(new Date(link.linked_at).getTime() / 1000)}:F>`;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x0099FF)
|
||||
.setTitle('📋 Informations du compte lié')
|
||||
.setThumbnail(targetUser.displayAvatarURL({ dynamic: true }))
|
||||
.addFields(
|
||||
{
|
||||
name: '👤 Discord',
|
||||
value: `**Nom:** ${targetUser.globalName || targetUser.username}\n**Mention:** <@${targetUser.id}>\n**ID:** \`${targetUser.id}\``,
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
name: '🎮 Palworld',
|
||||
value: `**Pseudo:** ${link.palworld_username}\n**Player ID:** \`${link.player_id || 'N/A'}\``,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '🎯 Steam',
|
||||
value: `**Steam ID:** \`${link.steam_id}\``,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '📅 Dates',
|
||||
value: `**Lié le:** ${linkedDate}\n**Dernière connexion:** ${lastConn}`,
|
||||
inline: false
|
||||
}
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la récupération des informations:', error);
|
||||
await interaction.editReply({
|
||||
content: '❌ Une erreur est survenue lors de la récupération des informations.',
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -325,25 +325,34 @@ const connectWebSocket = async (pterodactylToken, serverId) => {
|
||||
|
||||
if (linkData) {
|
||||
if (linkData.type === 'link') {
|
||||
const playerData = await getSteamIdFromPlayerName(linkData.playerName);
|
||||
|
||||
if (playerData) {
|
||||
await handleLinkCommand(linkData.playerName, playerData, linkData.code);
|
||||
// Ne plus vérifier si on doit fermer le WebSocket
|
||||
} else {
|
||||
console.log(`❌ Impossible de trouver le Steam ID pour ${linkData.playerName}`);
|
||||
}
|
||||
} else if (linkData.type === 'disconnect') {
|
||||
try {
|
||||
const result = await updateLastConnection(linkData.userId);
|
||||
if (result.changes > 0) {
|
||||
console.log(`✅ Dernière connexion mise à jour pour ${linkData.playerName} (${linkData.userId})`);
|
||||
} else {
|
||||
console.log(`ℹ️ Aucun compte lié trouvé pour ${linkData.playerName} (${linkData.userId})`);
|
||||
// Traiter de manière asynchrone sans bloquer le handler WebSocket
|
||||
(async () => {
|
||||
try {
|
||||
const playerData = await getSteamIdFromPlayerName(linkData.playerName);
|
||||
|
||||
if (playerData) {
|
||||
await handleLinkCommand(linkData.playerName, playerData, linkData.code);
|
||||
} else {
|
||||
console.log(`❌ Impossible de trouver le Steam ID pour ${linkData.playerName}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ Erreur lors du traitement de !lier pour ${linkData.playerName}:`, error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la mise à jour de la dernière connexion:', error);
|
||||
}
|
||||
})();
|
||||
} else if (linkData.type === 'disconnect') {
|
||||
// Traiter de manière asynchrone sans bloquer le handler WebSocket
|
||||
(async () => {
|
||||
try {
|
||||
const result = await updateLastConnection(linkData.userId);
|
||||
if (result.changes > 0) {
|
||||
console.log(`✅ Dernière connexion mise à jour pour ${linkData.playerName} (${linkData.userId})`);
|
||||
} else {
|
||||
console.log(`ℹ️ Aucun compte lié trouvé pour ${linkData.playerName} (${linkData.userId})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la mise à jour de la dernière connexion:', error);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user