From 8677ad506ae6c1f20eeea6b42de7fb0ab5dac37e Mon Sep 17 00:00:00 2001 From: Louis Mazin Date: Thu, 16 Apr 2026 00:34:59 +0200 Subject: [PATCH] test --- src/pterodactyl/displayer.js | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/src/pterodactyl/displayer.js b/src/pterodactyl/displayer.js index 8e350c7..f49ad05 100644 --- a/src/pterodactyl/displayer.js +++ b/src/pterodactyl/displayer.js @@ -31,38 +31,14 @@ const getMinecraftStatus = async () => { }; }; -const getPterodactylState = async (headers) => { - const panelUrl = process.env.PTERODACTYL_PANEL_URL; - const serverId = process.env.PTERODACTYL_SERVER_ID; - - if (!headers || !panelUrl || !serverId) { - return "inconnu"; - } - - try { - const stateResponse = await fetch(`${panelUrl}/api/client/servers/${serverId}/resources`, { - method: "GET", - headers - }); - - if (!stateResponse.ok) { - return "inconnu"; - } - - const stateData = await stateResponse.json(); - return stateData?.attributes?.current_state || "inconnu"; - } catch (error) { - return "inconnu"; - } -}; - -const buildPanelEmbed = (status, panelState) => { +const buildPanelEmbed = (status) => { const stateText = status.online ? "🟢 En ligne" : "🔴 Hors ligne"; const playersText = `${status.playersOnline}/${status.playersMax}`; + console.log(status.playerList); const playersListText = status.playerList.length > 0 ? status.playerList.join(", ") : "Aucun joueur connecte"; const message = new EmbedBuilder() .setColor('#0099ff') - .setDescription('# Informations sur le Serveur \n\n## :wireless: IP :\n### goofymon.louismazin.ovh\n\n## :repeat: État :\n### '+stateText+'\n\n## :busts_in_silhouette: Joueurs :\n### '+playersText+'\n\n## :video_game: Version :\n### '+status.version+'\n\n## :speech_balloon: MOTD :\n### '+status.motd+'\n\n## :bust_in_silhouette: Liste des joueurs :\n### '+playersListText); + .setDescription('# Informations sur le Serveur \n\n## :wireless: IP :\n### goofymon.louismazin.ovh\n\n## :repeat: État :\n### '+stateText+'\n\n## :busts_in_silhouette: Joueurs :\n### '+playersText+'\n\n## :video_game: Version :\n### '+status.version+'\n\n## :bust_in_silhouette: Liste des joueurs :\n### '+playersListText); return message; }; @@ -91,7 +67,7 @@ const resolvePanelMessage = async (client, channelId, messageId) => { return { channel, message: newMessage }; }; -const update = async (headers, client) => { +const update = async (client) => { try { const channelId = process.env.DISPLAYER_CHANNEL_ID; const messageId = process.env.DISPLAYER_MESSAGE_ID; @@ -102,8 +78,7 @@ const update = async (headers, client) => { } const status = await getMinecraftStatus(); - const panelState = await getPterodactylState(headers); - const embed = buildPanelEmbed(status, panelState); + const embed = buildPanelEmbed(status, ); const { message } = await resolvePanelMessage(client, channelId, messageId);