mirror of
https://github.com/arthur-pbty/LazyBot.git
synced 2026-06-03 23:36:37 +02:00
add counting system
This commit is contained in:
@@ -54,6 +54,10 @@
|
||||
<span class="nav-item-icon">🔊</span>
|
||||
Salons temporaires
|
||||
</a>
|
||||
<a class="nav-item" data-section="counting">
|
||||
<span class="nav-item-icon">🔢</span>
|
||||
Comptage
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -655,6 +659,45 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Section: Comptage -->
|
||||
<section class="config-section" id="section-counting">
|
||||
<div class="config-card">
|
||||
<div class="config-card-header">
|
||||
<div class="config-card-title">
|
||||
<span class="icon">🔢</span>
|
||||
<h3>Système de comptage</h3>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
<input type="checkbox" id="counting-enabled">
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="config-card-body">
|
||||
<div class="info-box">
|
||||
<strong>💡 Comment ça marche ?</strong><br>
|
||||
Les membres comptent à l'infini dans le salon dédié. Un membre ne peut pas compter deux fois de suite,
|
||||
ils doivent alterner. Si quelqu'un se trompe, le compteur repart à 0 !
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">Salon de comptage</label>
|
||||
<span class="form-sublabel">Le salon textuel où les membres peuvent compter</span>
|
||||
<select class="form-select" id="counting-channel"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">Compteur actuel</label>
|
||||
<input type="number" class="form-input" id="counting-current" disabled value="0">
|
||||
<span class="form-sublabel">Utilisez les commandes /counting-set, /counting-add, /counting-remove pour modifier</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-card-footer">
|
||||
<div id="status-counting-form" class="status-message"></div>
|
||||
<button type="button" class="btn btn-primary" id="save-counting">Sauvegarder</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -670,5 +713,6 @@
|
||||
<script src="/guild/levelForm.js"></script>
|
||||
<script src="/guild/economyForm.js"></script>
|
||||
<script src="/guild/privateroomForm.js"></script>
|
||||
<script src="/guild/countingForm.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// ===== COUNTING FORM =====
|
||||
(async function () {
|
||||
const enabledCheckbox = document.getElementById("counting-enabled");
|
||||
const channelSelect = document.getElementById("counting-channel");
|
||||
const currentCountInput = document.getElementById("counting-current");
|
||||
const saveBtn = document.getElementById("save-counting");
|
||||
|
||||
// Charger les salons textuels
|
||||
async function loadTextChannels() {
|
||||
try {
|
||||
const res = await fetch(`/api/bot/get-text-channels/${guildId}`);
|
||||
const channels = await res.json();
|
||||
channelSelect.innerHTML = '<option value="">-- Sélectionner un salon --</option>';
|
||||
channels.forEach(ch => {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = ch.id;
|
||||
opt.textContent = "#" + ch.name;
|
||||
channelSelect.appendChild(opt);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Erreur chargement salons textuels:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Charger la configuration
|
||||
async function loadConfig() {
|
||||
try {
|
||||
await loadTextChannels();
|
||||
|
||||
const res = await fetch(`/api/bot/get-counting-config/${guildId}`);
|
||||
const data = await res.json();
|
||||
|
||||
enabledCheckbox.checked = data.enabled;
|
||||
currentCountInput.value = data.currentCount || 0;
|
||||
|
||||
if (data.channelId) {
|
||||
channelSelect.value = data.channelId;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Erreur chargement config counting:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Sauvegarder
|
||||
saveBtn.addEventListener("click", async () => {
|
||||
saveBtn.disabled = true;
|
||||
saveBtn.textContent = "Sauvegarde...";
|
||||
|
||||
const data = {
|
||||
guildId,
|
||||
enabled: enabledCheckbox.checked,
|
||||
channelId: channelSelect.value || null
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch("/api/bot/save-counting-config", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
const result = await res.json();
|
||||
|
||||
if (result.success) {
|
||||
showStatus("status-counting-form", "Configuration sauvegardée ✅", "success");
|
||||
} else {
|
||||
showStatus("status-counting-form", "Erreur lors de la sauvegarde ❌", "error");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Erreur sauvegarde:", err);
|
||||
showStatus("status-counting-form", "Erreur de connexion ❌", "error");
|
||||
}
|
||||
|
||||
saveBtn.disabled = false;
|
||||
saveBtn.textContent = "Sauvegarder";
|
||||
});
|
||||
|
||||
// Init
|
||||
loadConfig();
|
||||
})();
|
||||
@@ -77,6 +77,11 @@
|
||||
<h3>Salons Temporaires</h3>
|
||||
<p>Créez des salons vocaux privés à la demande. Quand un membre rejoint le salon créateur, un salon personnel est créé automatiquement.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🔢</div>
|
||||
<h3>Jeu de Comptage</h3>
|
||||
<p>Un mini-jeu collaboratif où les membres comptent à l'infini. Ils doivent alterner et ne pas se tromper sinon le compteur repart à 0 !</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">⚙️</div>
|
||||
<h3>Dashboard Intuitif</h3>
|
||||
|
||||
Reference in New Issue
Block a user