fix timer

This commit is contained in:
Louis Mazin 2025-07-05 14:49:23 +02:00
parent b061c2e730
commit 42465fa5e8
2 changed files with 28 additions and 30 deletions

View File

@ -60,22 +60,21 @@ module.exports = {
var run = false; var run = false;
while (!run) { while (!run) {
setTimeout(async () => { await new Promise(resolve => setTimeout(resolve, 5000));
try { try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', { const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers headers: headers
}); });
const newState = checkResponse.data.attributes.current_state; const newState = checkResponse.data.attributes.current_state;
if (newState === 'running') { if (newState === 'running') {
run = true; run = true;
await interaction.editReply('✅ Le serveur Palworld a été redémarré avec succès !'); await interaction.editReply('✅ Le serveur Palworld a été redémarré avec succès !');
}
} catch (error) {
console.error('Erreur lors de la vérification de l\'état du serveur:', error);
} }
}, 5000); // Vérifier après 5 secondes } catch (error) {
console.error('Erreur lors de la vérification de l\'état du serveur:', error);
}
} }
} catch (error) { } catch (error) {

View File

@ -34,24 +34,23 @@ module.exports = {
var run = false; var run = false;
while (!run) { while (!run) {
setTimeout(async () => { await new Promise(resolve => setTimeout(resolve, 5000));
try { try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', { const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers headers: headers
}); });
const newState = checkResponse.data.attributes.current_state; const newState = checkResponse.data.attributes.current_state;
if (newState === 'running') { if (newState === 'running') {
run = true; run = true;
await interaction.editReply('✅ Le serveur Palworld a été démarré avec succès !'); await interaction.editReply('✅ Le serveur Palworld a été démarré avec succès !');
} else if (newState === 'starting') { } else if (newState === 'starting') {
await interaction.editReply('⏳ Le serveur Palworld est en cours de démarrage...'); await interaction.editReply('⏳ Le serveur Palworld est en cours de démarrage...');
}
} catch (error) {
console.error('Erreur lors de la vérification de l\'état du serveur:', error);
} }
}, 5000); // Vérifier après 5 secondes } catch (error) {
console.error('Erreur lors de la vérification de l\'état du serveur:', error);
}
} }
} catch (error) { } catch (error) {