test
This commit is contained in:
parent
9a53a3fa08
commit
8677ad506a
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user