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;
while (!run) {
setTimeout(async () => {
try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers
});
await new Promise(resolve => setTimeout(resolve, 5000));
try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers
});
const newState = checkResponse.data.attributes.current_state;
const newState = checkResponse.data.attributes.current_state;
if (newState === 'running') {
run = true;
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);
if (newState === 'running') {
run = true;
await interaction.editReply('✅ Le serveur Palworld a été redémarré avec succès !');
}
}, 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) {

View File

@ -34,24 +34,23 @@ module.exports = {
var run = false;
while (!run) {
setTimeout(async () => {
try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers
});
await new Promise(resolve => setTimeout(resolve, 5000));
try {
const checkResponse = await axios.get('https://panel.louismazin.ovh/api/client/servers/ae4a628f/resources', {
headers: headers
});
const newState = checkResponse.data.attributes.current_state;
const newState = checkResponse.data.attributes.current_state;
if (newState === 'running') {
run = true;
await interaction.editReply('✅ Le serveur Palworld a été démarré avec succès !');
} else if (newState === 'starting') {
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);
if (newState === 'running') {
run = true;
await interaction.editReply('✅ Le serveur Palworld a été démarré avec succès !');
} else if (newState === 'starting') {
await interaction.editReply('⏳ Le serveur Palworld est en cours de démarrage...');
}
}, 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) {