Spaces:
Runtime error
Runtime error
File size: 7,553 Bytes
c60bc87 08fd20d c60bc87 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FriendlyBot — Advanced Stats</title>
<link rel="icon" href="/logo.png" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
<style>
:root {
--bg: #0a0a1a; --surface: #12122a; --surface2: #1a1a3a; --border: rgba(255,255,255,0.08);
--text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
--accent: #5865F2; --radius: 16px; --red: #ED4245;
}
* { box-sizing: border-box; margin:0; padding:0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
header { max-width: 800px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
h1 { font-size: 28px; font-weight: 700; }
.btn {
display: inline-block; padding: 10px 20px; background: var(--accent);
color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px; border: none; cursor: pointer;
}
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
.container { max-width: 800px; margin: 0 auto; }
.card {
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
border: 1px solid var(--border); border-radius: var(--radius);
padding: 32px; margin-bottom: 30px;
}
.card h2 { font-size: 20px; margin-bottom: 12px; }
.card p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
.config-grid { display: grid; gap: 24px; }
.input-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select {
width: 100%; padding: 14px; background: var(--surface2); border: 1px solid var(--border);
border-radius: 10px; color: #fff; font-size: 15px; outline: none;
}
#guild-selector { margin-bottom: 30px; }
.server-select { width: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
.save-bar { position: sticky; bottom: 20px; background: var(--surface); border: 1px solid var(--border); padding: 16px 24px; border-radius: 100px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 100; }
</style>
</head>
<body>
<header>
<div style="display:flex; align-items:center; gap:16px">
<div style="font-size:32px">📊</div>
<h1>Advanced Stats</h1>
</div>
<div style="display:flex; gap:10px">
<a href="/premium" class="btn btn-secondary">Back to Premium</a>
<a href="/dashboard" class="btn btn-secondary">Dashboard</a>
</div>
</header>
<div class="container">
<div id="guild-selector">
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:10px">Select a Server to Configure</label>
<select id="server-list" class="server-select" onchange="loadConfig(this.value)">
<option value="">Loading your servers...</option>
</select>
</div>
<div class="card" id="config-card" style="display:none">
<h2>Leaderboards & Analytics</h2>
<p>Configure how stats are tracked and displayed in your server.</p>
<div class="config-grid">
<div class="input-group">
<label>Leaderboard Channel</label>
<select id="config-leaderboard-channel" onchange="checkChanges()">
<option value="">Select a channel...</option>
</select>
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">The bot will automatically update a leaderboard message in this channel.</p>
</div>
<div class="input-group">
<label>Auto-Post Stats</label>
<select id="config-stats-frequency" onchange="checkChanges()">
<option value="never">Never</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="monthly">Monthly</option>
</select>
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">How often should the bot post the top performers of the period?</p>
</div>
</div>
</div>
</div>
<div class="save-bar" id="save-bar" style="display:none; max-width:800px; margin: 0 auto;">
<span style="font-size:14px; font-weight:500">You have unsaved changes!</span>
<button class="btn" onclick="saveConfig()">Save Stats Settings</button>
</div>
<script>
let currentGuildId = null;
async function init() {
try {
const serversR = await fetch('/api/servers');
const serversData = await serversR.json();
const serverSelect = document.getElementById('server-list');
const servers = serversData.servers || [];
if (servers.length === 0) {
serverSelect.innerHTML = '<option value="">No manageable servers found</option>';
return;
}
serverSelect.innerHTML = '<option value="">-- Choose a Server --</option>' +
servers.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
} catch (e) { console.error(e); }
}
async function loadConfig(guildId) {
if (!guildId) {
document.getElementById('config-card').style.display = 'none';
document.getElementById('save-bar').style.display = 'none';
return;
}
currentGuildId = guildId;
document.getElementById('config-card').style.display = 'block';
try {
const [configR, channelsR] = await Promise.all([
fetch(`/api/config/${guildId}`),
fetch(`/api/channels/${guildId}`)
]);
const data = await configR.json();
const channels = await channelsR.json();
const channelSelect = document.getElementById('config-leaderboard-channel');
channelSelect.innerHTML = '<option value="">Select a channel...</option>' +
channels.map(c => `<option value="${c.id}" ${c.id === data.leaderboardChannel ? 'selected' : ''}>#${c.name}</option>`).join('');
document.getElementById('config-stats-frequency').value = data.statsFrequency || 'never';
document.getElementById('save-bar').style.display = 'none';
} catch (e) { alert('Failed to load configuration'); }
}
function checkChanges() {
if (!currentGuildId) return;
document.getElementById('save-bar').style.display = 'flex';
}
async function saveConfig() {
const leaderboardChannel = document.getElementById('config-leaderboard-channel').value;
const statsFrequency = document.getElementById('config-stats-frequency').value;
try {
const r = await fetch(`/api/config/${currentGuildId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ leaderboardChannel, statsFrequency })
});
const data = await r.json();
if (data.success) {
alert('✅ Stats settings saved!');
document.getElementById('save-bar').style.display = 'none';
} else {
alert('❌ Error: ' + data.error);
}
} catch (e) { alert('❌ Failed to save'); }
}
init();
</script>
</body>
</html>
|