Basic Discord functionality with assignments
This commit is contained in:
@@ -658,6 +658,39 @@ async function toggleEnemyStatus() {
|
||||
btn.textContent = "Stop Refresh";
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// Bot control (start/stop)
|
||||
// ---------------------------
|
||||
async function toggleBotControl() {
|
||||
const btn = document.getElementById("bot-control-btn");
|
||||
const isRunning = btn.dataset.running === "true";
|
||||
const action = isRunning ? "stop" : "start";
|
||||
|
||||
try {
|
||||
const res = await fetch("/api/bot_control", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ action })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
console.error("Bot control failed:", res.status);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
// Update button state
|
||||
btn.dataset.running = data.bot_running ? "true" : "false";
|
||||
btn.textContent = data.bot_running ? "Stop Bot" : "Start Bot";
|
||||
btn.style.backgroundColor = data.bot_running ? "#ff4444" : "#4CAF50";
|
||||
|
||||
console.log(`Bot ${data.bot_running ? "started" : "stopped"}`);
|
||||
} catch (err) {
|
||||
console.error("toggleBotControl error:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// Reset groups (server-side)
|
||||
// ---------------------------
|
||||
@@ -682,6 +715,10 @@ function wireUp() {
|
||||
if (enemyBtn) enemyBtn.addEventListener("click", populateEnemy);
|
||||
document.getElementById("friendly-status-btn").addEventListener("click", toggleFriendlyStatus);
|
||||
document.getElementById("enemy-status-btn").addEventListener("click", toggleEnemyStatus);
|
||||
|
||||
const botBtn = document.getElementById("bot-control-btn");
|
||||
if (botBtn) botBtn.addEventListener("click", toggleBotControl);
|
||||
|
||||
const resetBtn = document.getElementById("reset-groups-btn");
|
||||
if (resetBtn) resetBtn.addEventListener("click", resetGroups);
|
||||
|
||||
|
||||
@@ -198,6 +198,42 @@ button {
|
||||
}
|
||||
button:hover { background-color: #3399ff; }
|
||||
|
||||
/* Bot control button */
|
||||
.bot-btn {
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
padding: 0.6rem 1rem;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
border-radius: 8px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.bot-btn:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.bot-btn[data-running="true"] {
|
||||
background-color: #ff4444;
|
||||
}
|
||||
|
||||
/* Reset button */
|
||||
.reset-btn {
|
||||
background-color: #ff8800;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.reset-btn:hover {
|
||||
background-color: #ff6600;
|
||||
}
|
||||
|
||||
/* Top controls layout */
|
||||
.top-controls {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* scrollbar niceties for drop zones and lists */
|
||||
.member-list::-webkit-scrollbar, .drop-zone::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||
.member-list::-webkit-scrollbar-thumb, .drop-zone::-webkit-scrollbar-thumb { background: #66ccff; border-radius: 4px; }
|
||||
|
||||
Reference in New Issue
Block a user