Spaces:
Runtime error
Runtime error
Create package-lock.json
#1
by Brozy123 - opened
- .dockerignore +0 -9
- Dockerfile +10 -13
- README.md +8 -27
- app.py +0 -32
- bot.js +0 -149
- broadcast_system.js +0 -108
- commmands.txt +6 -8
- dashboard.html +44 -879
- db.js +0 -115
- discloud.config +7 -0
- discord-logo.svg +0 -1
- dmall.js +0 -188
- emergency_handler.js +0 -37
- grant_system.js +0 -51
- hyper_fix.js +0 -16
- index.js +0 -0
- league.html +0 -636
- lineupRenderer.js +146 -145
- lineup_persistence.js +0 -139
- network_fix.js +49 -25
- package.json +9 -15
- postinstall.js +0 -18
- premium.html +0 -179
- premiumStore.js +0 -104
- privacy.html +0 -66
- profiles.html +0 -180
- requirements.txt +11 -1
- roleStorage.js +1 -6
- roster.html +0 -137
- scheduling.html +0 -171
- scrimRenderer.js +0 -76
- server.js +88 -376
- stats.html +0 -174
- storage.js +60 -155
- style.css +245 -0
- tacticRenderer.js +0 -324
- tos.html +0 -61
- ultimate_fix.js +0 -12
- web.js +0 -60
.dockerignore
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
node_modules
|
| 2 |
-
.git
|
| 3 |
-
.cursor
|
| 4 |
-
data
|
| 5 |
-
sessions.json
|
| 6 |
-
*.log
|
| 7 |
-
.env
|
| 8 |
-
.kilocode
|
| 9 |
-
scratch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
FROM node:20
|
| 2 |
|
| 3 |
-
# Install
|
| 4 |
-
|
| 5 |
-
|
| 6 |
libfontconfig1 \
|
| 7 |
libfreetype6 \
|
|
|
|
| 8 |
libcairo2 \
|
| 9 |
libjpeg62-turbo \
|
| 10 |
libpng16-16 \
|
|
@@ -13,19 +14,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 13 |
fonts-dejavu-core \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
|
|
|
| 16 |
USER node
|
| 17 |
WORKDIR /home/node/app
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
COPY --chown=node package.json
|
| 21 |
-
RUN npm
|
| 22 |
|
| 23 |
-
# Copy the rest (respects .dockerignore)
|
| 24 |
COPY --chown=node . .
|
| 25 |
|
| 26 |
-
EXPOSE 7860
|
| 27 |
-
|
| 28 |
ENV PORT=7860
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
CMD ["node", "index.js"]
|
|
|
|
| 1 |
+
FROM node:20
|
| 2 |
|
| 3 |
+
# Install native dependencies required by @napi-rs/canvas for image rendering
|
| 4 |
+
USER root
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
libfontconfig1 \
|
| 7 |
libfreetype6 \
|
| 8 |
+
libpango1.0-0 \
|
| 9 |
libcairo2 \
|
| 10 |
libjpeg62-turbo \
|
| 11 |
libpng16-16 \
|
|
|
|
| 14 |
fonts-dejavu-core \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# The node image already has a user 'node' with UID 1000
|
| 18 |
USER node
|
| 19 |
WORKDIR /home/node/app
|
| 20 |
|
| 21 |
+
# Copy only package.json (NOT lock file) to force fresh platform-native install
|
| 22 |
+
COPY --chown=node package.json ./
|
| 23 |
+
RUN npm install
|
| 24 |
|
|
|
|
| 25 |
COPY --chown=node . .
|
| 26 |
|
|
|
|
|
|
|
| 27 |
ENV PORT=7860
|
| 28 |
+
CMD ["node", "--dns-result-order=ipv4first", "index.js"]
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,39 +1,20 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
In the Space → **Settings** → **Variables and secrets** → **New secret**:
|
| 19 |
-
- `BOT_TOKEN` — your Discord bot token (same value you use locally in `.env`).
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
[Applications](https://discord.com/developers/applications) → your bot → **Bot** → under **Privileged Gateway Intents** enable **Presence** is optional; enable **Server Members Intent** and **Message Content Intent** (this codebase requests both). Save, then **restart** the Space.
|
| 25 |
-
|
| 26 |
-
3. **Sleep vs true 24/7**
|
| 27 |
-
On **free** hardware, Spaces can **pause after inactivity** (policy changes over time; check [Spaces hardware](https://huggingface.co/docs/hub/spaces-overview)). The bot already **HTTP-pings its own public URL** every ~2 minutes when HF env vars are present (`SPACE_HOST`, `SPACE_ID`, or `SPACE_AUTHOR_NAME` + `SPACE_REPO_NAME`) to reduce idle sleep when the Space is running.
|
| 28 |
-
|
| 29 |
-
For **guaranteed** always-on behavior (no sleep, stronger SLA), use **paid** Space hardware and, if offered in your Space settings, disable or extend **sleep time**.
|
| 30 |
-
|
| 31 |
-
4. **After every git push**
|
| 32 |
-
HF rebuilds the Docker image and restarts the Space. Wait until the Space shows **Running**; check **Logs** for `Slash commands synchronized` and Discord online messages.
|
| 33 |
-
|
| 34 |
-
5. **Invite the bot**
|
| 35 |
-
Use an invite URL that includes the **`applications.commands`** scope so slash commands appear in your server.
|
| 36 |
-
|
| 37 |
-
## Local Windows
|
| 38 |
-
|
| 39 |
-
Use `start.bat` in this folder (keeps restarting `node index.js` on your PC). Your PC must stay on for the bot to stay online locally.
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SentryNode / Lineup Bot
|
| 3 |
+
emoji: 🤖
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
This repository contains a Flask wrapper and Discord bot for use with a Docker-based Hugging Face Space.
|
| 11 |
|
| 12 |
+
The Discord bot startup is now isolated in `bot_runner.py`, so the bot runtime is kept separate from the web app and other code.
|
| 13 |
|
| 14 |
+
A dedicated supervisor is now included in `bot_supervisor.py`, which keeps the bot running and automatically restarts it whenever the code changes or the bot process stops.
|
| 15 |
|
| 16 |
+
When `server.py` is launched as the application entrypoint, it starts `bot_supervisor.py` automatically, so the bot will come online without manual startup.
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
If you want to run the bot directly in a standalone environment, use `python bot_supervisor.py`.
|
| 19 |
|
| 20 |
+
Use the root `server.py` as the app entrypoint. If you want to deploy the new bot instead, place its files at the repository root or use a separate Space repository.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
from flask import Flask, send_from_directory, redirect
|
| 2 |
-
|
| 3 |
-
app = Flask(__name__, static_folder='.', static_url_path='/')
|
| 4 |
-
|
| 5 |
-
@app.route('/')
|
| 6 |
-
def index():
|
| 7 |
-
return send_from_directory('.', 'dashboard.html')
|
| 8 |
-
|
| 9 |
-
@app.route('/league')
|
| 10 |
-
def league():
|
| 11 |
-
# Serve the league page (alias)
|
| 12 |
-
return send_from_directory('.', 'league.html')
|
| 13 |
-
|
| 14 |
-
@app.route('/league/')
|
| 15 |
-
def league_trailing_slash():
|
| 16 |
-
# Redirect trailing slash to canonical path
|
| 17 |
-
return redirect('/league.html')
|
| 18 |
-
|
| 19 |
-
@app.route('/league.html')
|
| 20 |
-
def league_html():
|
| 21 |
-
# Alias to support environments that request the .html path explicitly
|
| 22 |
-
return send_from_directory('.', 'league.html')
|
| 23 |
-
|
| 24 |
-
@app.route('/<path:path>')
|
| 25 |
-
def static_proxy(path):
|
| 26 |
-
# Serve static files (images, js, css) if referenced
|
| 27 |
-
return send_from_directory('.', path)
|
| 28 |
-
|
| 29 |
-
if __name__ == '__main__':
|
| 30 |
-
import os
|
| 31 |
-
port = int(os.environ.get('PORT', 8000))
|
| 32 |
-
app.run(host='0.0.0.0', port=port)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
| 1 |
-
"use strict";
|
| 2 |
-
const { Client, GatewayIntentBits, MessageFlags } = require("discord.js");
|
| 3 |
-
const db = require("./db");
|
| 4 |
-
|
| 5 |
-
// Default configuration is robust enough for most networks
|
| 6 |
-
const client = new Client({
|
| 7 |
-
intents: [
|
| 8 |
-
GatewayIntentBits.Guilds,
|
| 9 |
-
GatewayIntentBits.GuildMessages,
|
| 10 |
-
GatewayIntentBits.MessageContent
|
| 11 |
-
],
|
| 12 |
-
rest: {
|
| 13 |
-
timeout: 15000, // 15s timeout
|
| 14 |
-
retries: 5, // Retry up to 5 times
|
| 15 |
-
},
|
| 16 |
-
ws: {
|
| 17 |
-
large_threshold: 50, // Reduce initial load for faster startup
|
| 18 |
-
}
|
| 19 |
-
});
|
| 20 |
-
|
| 21 |
-
client.once("ready", () => {
|
| 22 |
-
console.log(`[BOT] Logged in as ${client.user.tag}`);
|
| 23 |
-
console.log(`[BOT] Serving ${client.guilds.cache.size} guilds`);
|
| 24 |
-
});
|
| 25 |
-
|
| 26 |
-
client.on("messageCreate", (message) => {
|
| 27 |
-
if (message.author.bot) return;
|
| 28 |
-
|
| 29 |
-
const content = message.content.trim();
|
| 30 |
-
const prefix = "!";
|
| 31 |
-
|
| 32 |
-
// Track command usage (only if functions exist)
|
| 33 |
-
try {
|
| 34 |
-
if (db.trackServerActivity) db.trackServerActivity(message.guildId, message.guild?.name || "Unknown", message.guild?.memberCount || 0);
|
| 35 |
-
if (db.trackCommandUsage) db.trackCommandUsage(message.guildId, message.author.id, message.author.tag, content.split(" ")[0]);
|
| 36 |
-
} catch (e) {
|
| 37 |
-
console.error("[ERROR] Tracking failed:", e.message);
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
if (content === `${prefix}ping`) {
|
| 41 |
-
message.reply(`Pong! Latency: ${client.ws.ping}ms`);
|
| 42 |
-
return;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
// !servers-info
|
| 46 |
-
if (content === `${prefix}servers-info`) {
|
| 47 |
-
const allServers = db.getServerStats();
|
| 48 |
-
const globalStats = db.getGlobalStats();
|
| 49 |
-
|
| 50 |
-
if (!allServers || allServers.length === 0) {
|
| 51 |
-
message.reply("No server data available yet.");
|
| 52 |
-
return;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
let embed = `\`\`\`
|
| 56 |
-
📊 SERVERS INFO - GLOBAL STATS
|
| 57 |
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 58 |
-
Total Servers: ${client.guilds.cache.size}
|
| 59 |
-
Total Commands Used: ${globalStats?.total_commands || 0}
|
| 60 |
-
Active Users: ${globalStats?.total_users || 0}
|
| 61 |
-
\`\`\`\n`;
|
| 62 |
-
|
| 63 |
-
embed += `\n**📍 Server Activity (Top 10):**\n`;
|
| 64 |
-
|
| 65 |
-
allServers.slice(0, 10).forEach((server, index) => {
|
| 66 |
-
embed += `\n**${index + 1}. ${server.guild_name}** (ID: ${server.guild_id})\n`;
|
| 67 |
-
embed += ` • Members: ${server.member_count || 'N/A'}\n`;
|
| 68 |
-
embed += ` • Commands: ${server.commands_used}\n`;
|
| 69 |
-
embed += ` • Last Activity: <t:${Math.floor(new Date(server.last_activity).getTime() / 1000)}:R>\n`;
|
| 70 |
-
|
| 71 |
-
// Get top 5 command users for this server
|
| 72 |
-
const topUsers = db.getTopCommandUsers(server.guild_id, 5);
|
| 73 |
-
if (topUsers && topUsers.length > 0) {
|
| 74 |
-
embed += ` • Top Users:\n`;
|
| 75 |
-
topUsers.forEach((user, idx) => {
|
| 76 |
-
embed += ` ${idx + 1}. ${user.user_tag} (${user.count} commands)\n`;
|
| 77 |
-
});
|
| 78 |
-
}
|
| 79 |
-
});
|
| 80 |
-
|
| 81 |
-
embed += `\n\n**📋 All Connected Servers:**\n`;
|
| 82 |
-
const allConnectedServers = client.guilds.cache.map(guild => `• ${guild.name} (${guild.memberCount} members)`).join("\n");
|
| 83 |
-
|
| 84 |
-
if (allConnectedServers.length > 2000) {
|
| 85 |
-
embed += allConnectedServers.substring(0, 2000) + "...\n*(List truncated - too many servers)*";
|
| 86 |
-
} else {
|
| 87 |
-
embed += allConnectedServers;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
if (embed.length > 2000) {
|
| 91 |
-
message.reply(embed.substring(0, 1990) + "...");
|
| 92 |
-
} else {
|
| 93 |
-
message.reply(embed);
|
| 94 |
-
}
|
| 95 |
-
return;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
// !roster-add @User Role [in Team Name]
|
| 99 |
-
if (content.startsWith(`${prefix}roster-add`)) {
|
| 100 |
-
const fullText = content.slice(`${prefix}roster-add`.length).trim();
|
| 101 |
-
|
| 102 |
-
// Match: <@123456789> Role Name in Team Name
|
| 103 |
-
// Or: <@123456789> Role Name
|
| 104 |
-
const user = message.mentions.users.first();
|
| 105 |
-
if (!user) {
|
| 106 |
-
message.reply("Usage: `!roster-add @User Role [in Team Name]`");
|
| 107 |
-
return;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
// Remove the mention from the string to parse the rest
|
| 111 |
-
const rest = fullText.replace(/<@\d+>\s?/, "").trim();
|
| 112 |
-
|
| 113 |
-
let role = "Member";
|
| 114 |
-
let teamName = "General";
|
| 115 |
-
|
| 116 |
-
// Check for " in " to split role and team
|
| 117 |
-
const inIndex = rest.lastIndexOf(" in ");
|
| 118 |
-
if (inIndex > -1) {
|
| 119 |
-
role = rest.substring(0, inIndex).trim() || "Member";
|
| 120 |
-
teamName = rest.substring(inIndex + 4).trim() || "General";
|
| 121 |
-
} else {
|
| 122 |
-
role = rest || "Member";
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
const userTag = user.tag;
|
| 126 |
-
db.addRoster(teamName, userTag, role);
|
| 127 |
-
message.reply(`✅ Added **${userTag}** as **${role}** to **${teamName}**.`);
|
| 128 |
-
}
|
| 129 |
-
});
|
| 130 |
-
|
| 131 |
-
client.on("interactionCreate", async (interaction) => {
|
| 132 |
-
if (!interaction.isChatInputCommand()) return;
|
| 133 |
-
|
| 134 |
-
if (interaction.commandName === "ping") {
|
| 135 |
-
await interaction.reply({ content: `Latency: ${client.ws.ping}ms`, flags: MessageFlags.Ephemeral });
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
if (interaction.commandName === "roster-add") {
|
| 139 |
-
const team = interaction.options.getString("team") || "General";
|
| 140 |
-
const user = interaction.options.getUser("user");
|
| 141 |
-
const role = interaction.options.getString("role") || "Member";
|
| 142 |
-
const userTag = user ? user.tag : "Unknown";
|
| 143 |
-
|
| 144 |
-
db.addRoster(team, userTag, role);
|
| 145 |
-
await interaction.reply({ content: `✅ Added **${userTag}** as **${role}** to **${team}**.`, flags: MessageFlags.Ephemeral });
|
| 146 |
-
}
|
| 147 |
-
});
|
| 148 |
-
|
| 149 |
-
module.exports = { client };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
broadcast_system.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
| 1 |
-
const storage = require('./storage');
|
| 2 |
-
const { EmbedBuilder } = require('discord.js');
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* broadcast_system.js
|
| 6 |
-
* Handles global announcements and message tracking
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
async function broadcast(client, content, sender) {
|
| 10 |
-
const broadcastId = Date.now().toString();
|
| 11 |
-
const sentMessages = [];
|
| 12 |
-
const timestamp = new Date().toISOString();
|
| 13 |
-
|
| 14 |
-
const embed = new EmbedBuilder()
|
| 15 |
-
.setTitle("📢 Global Announcement")
|
| 16 |
-
.setDescription(content)
|
| 17 |
-
.setColor('#5865F2')
|
| 18 |
-
.setFooter({ text: `FriendlyBot Official | ID: ${broadcastId}` })
|
| 19 |
-
.setTimestamp();
|
| 20 |
-
|
| 21 |
-
for (const guild of client.guilds.cache.values()) {
|
| 22 |
-
const config = storage.data.config[guild.id] || {};
|
| 23 |
-
// Respect the opt-out toggle (defaulting to false based on user request)
|
| 24 |
-
if (!!config.postEnabled) {
|
| 25 |
-
try {
|
| 26 |
-
// Determine target channel: either configured one or system channel
|
| 27 |
-
const channelId = config.postChannelId;
|
| 28 |
-
let channel = null;
|
| 29 |
-
|
| 30 |
-
if (channelId) {
|
| 31 |
-
channel = await guild.channels.fetch(channelId).catch(() => null);
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
if (!channel) {
|
| 35 |
-
channel = guild.systemChannel || guild.channels.cache.find(c => c.isTextBased() && c.permissionsFor(guild.members.me).has('SendMessages'));
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
if (channel) {
|
| 39 |
-
const msg = await channel.send({ embeds: [embed] });
|
| 40 |
-
sentMessages.push({
|
| 41 |
-
guildId: guild.id,
|
| 42 |
-
guildName: guild.name,
|
| 43 |
-
channelId: channel.id,
|
| 44 |
-
messageId: msg.id
|
| 45 |
-
});
|
| 46 |
-
}
|
| 47 |
-
} catch (err) {
|
| 48 |
-
console.error(`[Broadcast] Failed to send to ${guild.name}:`, err.message);
|
| 49 |
-
}
|
| 50 |
-
}
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
// Save to history
|
| 54 |
-
storage.data.broadcasts.push({
|
| 55 |
-
id: broadcastId,
|
| 56 |
-
content: content,
|
| 57 |
-
senderTag: sender.tag,
|
| 58 |
-
senderId: sender.id,
|
| 59 |
-
timestamp: timestamp,
|
| 60 |
-
messages: sentMessages
|
| 61 |
-
});
|
| 62 |
-
storage.save('broadcasts');
|
| 63 |
-
|
| 64 |
-
return { id: broadcastId, count: sentMessages.length };
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
async function removeBroadcast(client, broadcastIdOrText) {
|
| 68 |
-
// Find the broadcast entry
|
| 69 |
-
const entryIndex = storage.data.broadcasts.findIndex(b => b.id === broadcastIdOrText || b.content.includes(broadcastIdOrText));
|
| 70 |
-
if (entryIndex === -1) return { success: false, message: "Broadcast not found in history." };
|
| 71 |
-
|
| 72 |
-
const entry = storage.data.broadcasts[entryIndex];
|
| 73 |
-
let removedCount = 0;
|
| 74 |
-
|
| 75 |
-
for (const msgInfo of entry.messages) {
|
| 76 |
-
try {
|
| 77 |
-
const guild = client.guilds.cache.get(msgInfo.guildId);
|
| 78 |
-
if (guild) {
|
| 79 |
-
const channel = await guild.channels.fetch(msgInfo.channelId).catch(() => null);
|
| 80 |
-
if (channel) {
|
| 81 |
-
const msg = await channel.messages.fetch(msgInfo.messageId).catch(() => null);
|
| 82 |
-
if (msg) {
|
| 83 |
-
await msg.delete();
|
| 84 |
-
removedCount++;
|
| 85 |
-
}
|
| 86 |
-
}
|
| 87 |
-
}
|
| 88 |
-
} catch (err) {
|
| 89 |
-
console.error(`[Broadcast] Failed to remove from guild ${msgInfo.guildId}:`, err.message);
|
| 90 |
-
}
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
// Remove from history
|
| 94 |
-
storage.data.broadcasts.splice(entryIndex, 1);
|
| 95 |
-
storage.save('broadcasts');
|
| 96 |
-
|
| 97 |
-
return { success: true, count: removedCount };
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
function getBroadcastHistory() {
|
| 101 |
-
return storage.data.broadcasts;
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
module.exports = {
|
| 105 |
-
broadcast,
|
| 106 |
-
removeBroadcast,
|
| 107 |
-
getBroadcastHistory
|
| 108 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commmands.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
--- ⚽ MATCH & LINEUP MANAGEMENT ---
|
| 4 |
!friendly /friendly - Start a standard lineup vote for players to join.
|
| 5 |
-
!leaguematch /leaguematch - Schedule a professional league match with an opponent, link, and
|
| 6 |
!lineup /lineup - (Admin/Staff) Generate the standard interactive lineup board.
|
| 7 |
!managerlineup /managerlineup - (Admin/Staff) Open the GUI editor to draft players interactively.
|
| 8 |
!lineupimage /lineupimage - Generate a high-quality visual representation of the current starting lineup.
|
|
@@ -10,16 +10,14 @@
|
|
| 10 |
|
| 11 |
--- 📈 COMPETITION & STATS ---
|
| 12 |
!top /top - 🏆 Show the Top 10 most active players in the server.
|
| 13 |
-
!profile /profile - 🎴 Generate a custom profile card
|
| 14 |
-
!profileimage /profileimage - 🎨 Generate a high-quality visual profile image card.
|
| 15 |
-
!motm /motm - 🌟 (Admin/Staff) Grant the "Man of the Match" award to a player.
|
| 16 |
!record /record - 📊 View the server's global Win/Loss/Draw record.
|
| 17 |
-
!win /win - (Admin/Staff) Record a victory
|
| 18 |
-
!loss /loss - (Admin/Staff) Record a defeat
|
| 19 |
-
!draw /draw - (Admin/Staff) Record a draw
|
| 20 |
|
| 21 |
--- ⚙️ SYSTEM & STAFF SETUP ---
|
| 22 |
-
!setup /setup - (Admin Only) Opens the interactive settings dropdown panel
|
| 23 |
!addrole /addrole - (Admin Only) Add a role to the bot staff whitelist.
|
| 24 |
!removerole /removerole - (Admin Only) Remove a role from the bot staff whitelist.
|
| 25 |
!giverole /giverole - (Admin Only) Give a role to every member who already has the required roles.
|
|
|
|
| 2 |
|
| 3 |
--- ⚽ MATCH & LINEUP MANAGEMENT ---
|
| 4 |
!friendly /friendly - Start a standard lineup vote for players to join.
|
| 5 |
+
!leaguematch /leaguematch - Schedule a professional league match with an opponent, link, and optional time.
|
| 6 |
!lineup /lineup - (Admin/Staff) Generate the standard interactive lineup board.
|
| 7 |
!managerlineup /managerlineup - (Admin/Staff) Open the GUI editor to draft players interactively.
|
| 8 |
!lineupimage /lineupimage - Generate a high-quality visual representation of the current starting lineup.
|
|
|
|
| 10 |
|
| 11 |
--- 📈 COMPETITION & STATS ---
|
| 12 |
!top /top - 🏆 Show the Top 10 most active players in the server.
|
| 13 |
+
!profile /profile - 🎴 Generate a custom FIFA-style profile card with player stats.
|
|
|
|
|
|
|
| 14 |
!record /record - 📊 View the server's global Win/Loss/Draw record.
|
| 15 |
+
!win /win - (Admin/Staff) Record a victory into the server record.
|
| 16 |
+
!loss /loss - (Admin/Staff) Record a defeat into the server record.
|
| 17 |
+
!draw /draw - (Admin/Staff) Record a draw into the server record.
|
| 18 |
|
| 19 |
--- ⚙️ SYSTEM & STAFF SETUP ---
|
| 20 |
+
!setup /setup - (Admin Only) Opens the interactive settings dropdown panel.
|
| 21 |
!addrole /addrole - (Admin Only) Add a role to the bot staff whitelist.
|
| 22 |
!removerole /removerole - (Admin Only) Remove a role from the bot staff whitelist.
|
| 23 |
!giverole /giverole - (Admin Only) Give a role to every member who already has the required roles.
|
dashboard.html
CHANGED
|
@@ -24,37 +24,6 @@
|
|
| 24 |
--text-mid: rgba(255,255,255,0.7);
|
| 25 |
--radius: 16px;
|
| 26 |
--radius-sm: 10px;
|
| 27 |
-
--gold: #FFD700;
|
| 28 |
-
--gold-glow: rgba(255, 215, 0, 0.2);
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
.premium-locked {
|
| 32 |
-
opacity: 0.6;
|
| 33 |
-
filter: grayscale(0.8);
|
| 34 |
-
cursor: not-allowed !important;
|
| 35 |
-
position: relative;
|
| 36 |
-
}
|
| 37 |
-
.premium-locked::after {
|
| 38 |
-
content: '🔒 LOCKED';
|
| 39 |
-
position: absolute;
|
| 40 |
-
top: 12px;
|
| 41 |
-
right: 12px;
|
| 42 |
-
background: rgba(0,0,0,0.5);
|
| 43 |
-
color: white;
|
| 44 |
-
padding: 4px 8px;
|
| 45 |
-
border-radius: 4px;
|
| 46 |
-
font-size: 10px;
|
| 47 |
-
font-weight: 800;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
.stat-card.premium-unlocked {
|
| 51 |
-
border-color: var(--gold) !important;
|
| 52 |
-
background: linear-gradient(145deg, var(--surface), rgba(255,215,0,0.05)) !important;
|
| 53 |
-
box-shadow: 0 8px 32px var(--gold-glow) !important;
|
| 54 |
-
}
|
| 55 |
-
.stat-card.premium-unlocked:hover {
|
| 56 |
-
transform: translateY(-3px) scale(1.02);
|
| 57 |
-
box-shadow: 0 12px 48px var(--gold-glow) !important;
|
| 58 |
}
|
| 59 |
|
| 60 |
body {
|
|
@@ -381,476 +350,10 @@ body {
|
|
| 381 |
.log-line.error { color: var(--red); }
|
| 382 |
.log-line.warn { color: var(--yellow); }
|
| 383 |
|
| 384 |
-
/* Responsive
|
| 385 |
@media (max-width: 768px) {
|
| 386 |
-
.sidebar {
|
| 387 |
-
|
| 388 |
-
padding: 16px 12px;
|
| 389 |
-
}
|
| 390 |
-
.main {
|
| 391 |
-
margin-left: 280px;
|
| 392 |
-
padding: 20px 16px;
|
| 393 |
-
}
|
| 394 |
-
.topbar {
|
| 395 |
-
flex-direction: column;
|
| 396 |
-
align-items: flex-start;
|
| 397 |
-
gap: 12px;
|
| 398 |
-
}
|
| 399 |
-
.topbar h2 {
|
| 400 |
-
font-size: 22px;
|
| 401 |
-
}
|
| 402 |
-
.topbar-right {
|
| 403 |
-
width: 100%;
|
| 404 |
-
justify-content: space-between;
|
| 405 |
-
}
|
| 406 |
-
.stats-grid {
|
| 407 |
-
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
| 408 |
-
gap: 12px;
|
| 409 |
-
}
|
| 410 |
-
.stat-card {
|
| 411 |
-
padding: 16px;
|
| 412 |
-
}
|
| 413 |
-
.stat-card .value {
|
| 414 |
-
font-size: 28px;
|
| 415 |
-
}
|
| 416 |
-
.stat-card .label {
|
| 417 |
-
font-size: 11px;
|
| 418 |
-
}
|
| 419 |
-
.panel {
|
| 420 |
-
margin-bottom: 16px;
|
| 421 |
-
}
|
| 422 |
-
.actions-grid {
|
| 423 |
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 424 |
-
padding: 16px;
|
| 425 |
-
gap: 12px;
|
| 426 |
-
}
|
| 427 |
-
.server-row {
|
| 428 |
-
flex-direction: column;
|
| 429 |
-
align-items: flex-start;
|
| 430 |
-
padding: 12px 16px;
|
| 431 |
-
gap: 8px;
|
| 432 |
-
}
|
| 433 |
-
.server-info {
|
| 434 |
-
width: 100%;
|
| 435 |
-
flex-direction: column;
|
| 436 |
-
}
|
| 437 |
-
.server-rank {
|
| 438 |
-
align-self: flex-start;
|
| 439 |
-
}
|
| 440 |
-
}
|
| 441 |
-
|
| 442 |
-
/* Responsive - Mobile Phones (600px and below) */
|
| 443 |
-
@media (max-width: 600px) {
|
| 444 |
-
:root {
|
| 445 |
-
--radius: 12px;
|
| 446 |
-
--radius-sm: 8px;
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
body {
|
| 450 |
-
font-size: 14px;
|
| 451 |
-
}
|
| 452 |
-
|
| 453 |
-
.sidebar {
|
| 454 |
-
position: fixed;
|
| 455 |
-
z-index: 200;
|
| 456 |
-
width: 100%;
|
| 457 |
-
height: auto;
|
| 458 |
-
max-height: 0;
|
| 459 |
-
overflow: hidden;
|
| 460 |
-
transition: max-height 0.3s ease;
|
| 461 |
-
border-right: none;
|
| 462 |
-
border-bottom: 1px solid var(--border);
|
| 463 |
-
padding: 0;
|
| 464 |
-
display: flex;
|
| 465 |
-
flex-direction: row;
|
| 466 |
-
background: var(--surface);
|
| 467 |
-
}
|
| 468 |
-
|
| 469 |
-
.sidebar.mobile-open {
|
| 470 |
-
max-height: 100vh;
|
| 471 |
-
padding: 16px;
|
| 472 |
-
overflow-y: auto;
|
| 473 |
-
flex-direction: column;
|
| 474 |
-
}
|
| 475 |
-
|
| 476 |
-
.sidebar-brand {
|
| 477 |
-
padding: 8px;
|
| 478 |
-
border: none;
|
| 479 |
-
margin: 0;
|
| 480 |
-
min-width: 120px;
|
| 481 |
-
}
|
| 482 |
-
|
| 483 |
-
.sidebar-brand img {
|
| 484 |
-
width: 32px;
|
| 485 |
-
}
|
| 486 |
-
|
| 487 |
-
.sidebar-brand span {
|
| 488 |
-
font-size: 14px;
|
| 489 |
-
}
|
| 490 |
-
|
| 491 |
-
.sidebar-nav {
|
| 492 |
-
display: none;
|
| 493 |
-
}
|
| 494 |
-
|
| 495 |
-
.sidebar.mobile-open .sidebar-nav {
|
| 496 |
-
display: flex;
|
| 497 |
-
}
|
| 498 |
-
|
| 499 |
-
.sidebar-footer {
|
| 500 |
-
display: none;
|
| 501 |
-
}
|
| 502 |
-
|
| 503 |
-
.sidebar.mobile-open .sidebar-footer {
|
| 504 |
-
display: block;
|
| 505 |
-
}
|
| 506 |
-
|
| 507 |
-
.mobile-menu-toggle {
|
| 508 |
-
display: flex;
|
| 509 |
-
align-items: center;
|
| 510 |
-
justify-content: center;
|
| 511 |
-
width: 40px;
|
| 512 |
-
height: 40px;
|
| 513 |
-
background: var(--surface2);
|
| 514 |
-
border: 1px solid var(--border);
|
| 515 |
-
border-radius: var(--radius-sm);
|
| 516 |
-
cursor: pointer;
|
| 517 |
-
padding: 0;
|
| 518 |
-
margin-left: auto;
|
| 519 |
-
color: var(--text);
|
| 520 |
-
}
|
| 521 |
-
|
| 522 |
-
.main {
|
| 523 |
-
margin-left: 0;
|
| 524 |
-
padding: 16px 12px;
|
| 525 |
-
margin-top: 0;
|
| 526 |
-
}
|
| 527 |
-
|
| 528 |
-
.main.sidebar-mobile-open {
|
| 529 |
-
margin-top: 60px;
|
| 530 |
-
}
|
| 531 |
-
|
| 532 |
-
.topbar {
|
| 533 |
-
flex-direction: column;
|
| 534 |
-
align-items: flex-start;
|
| 535 |
-
gap: 8px;
|
| 536 |
-
margin-bottom: 16px;
|
| 537 |
-
}
|
| 538 |
-
|
| 539 |
-
.topbar h2 {
|
| 540 |
-
font-size: 20px;
|
| 541 |
-
font-weight: 700;
|
| 542 |
-
}
|
| 543 |
-
|
| 544 |
-
.topbar-right {
|
| 545 |
-
width: 100%;
|
| 546 |
-
flex-wrap: wrap;
|
| 547 |
-
gap: 8px;
|
| 548 |
-
}
|
| 549 |
-
|
| 550 |
-
.refresh-btn {
|
| 551 |
-
padding: 6px;
|
| 552 |
-
width: 36px;
|
| 553 |
-
height: 36px;
|
| 554 |
-
}
|
| 555 |
-
|
| 556 |
-
.status-pill {
|
| 557 |
-
font-size: 12px;
|
| 558 |
-
padding: 6px 12px;
|
| 559 |
-
}
|
| 560 |
-
|
| 561 |
-
.user-pill {
|
| 562 |
-
padding: 6px 10px;
|
| 563 |
-
gap: 6px;
|
| 564 |
-
}
|
| 565 |
-
|
| 566 |
-
.user-pill img {
|
| 567 |
-
width: 24px;
|
| 568 |
-
height: 24px;
|
| 569 |
-
}
|
| 570 |
-
|
| 571 |
-
.user-pill span {
|
| 572 |
-
font-size: 12px;
|
| 573 |
-
}
|
| 574 |
-
|
| 575 |
-
.stats-grid {
|
| 576 |
-
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
| 577 |
-
gap: 10px;
|
| 578 |
-
margin-bottom: 16px;
|
| 579 |
-
}
|
| 580 |
-
|
| 581 |
-
.stat-card {
|
| 582 |
-
padding: 12px;
|
| 583 |
-
border-radius: var(--radius-sm);
|
| 584 |
-
}
|
| 585 |
-
|
| 586 |
-
.stat-card .label {
|
| 587 |
-
font-size: 10px;
|
| 588 |
-
letter-spacing: 0px;
|
| 589 |
-
}
|
| 590 |
-
|
| 591 |
-
.stat-card .value {
|
| 592 |
-
font-size: 24px;
|
| 593 |
-
margin-top: 4px;
|
| 594 |
-
}
|
| 595 |
-
|
| 596 |
-
.stat-card .sub {
|
| 597 |
-
font-size: 10px;
|
| 598 |
-
margin-top: 4px;
|
| 599 |
-
}
|
| 600 |
-
|
| 601 |
-
.stat-card:hover {
|
| 602 |
-
transform: translateY(-1px);
|
| 603 |
-
}
|
| 604 |
-
|
| 605 |
-
.premium-locked::after {
|
| 606 |
-
font-size: 8px;
|
| 607 |
-
padding: 2px 4px;
|
| 608 |
-
top: 8px;
|
| 609 |
-
right: 8px;
|
| 610 |
-
}
|
| 611 |
-
|
| 612 |
-
.login-card {
|
| 613 |
-
width: 95vw;
|
| 614 |
-
max-width: 340px;
|
| 615 |
-
padding: 32px 20px;
|
| 616 |
-
border-radius: var(--radius);
|
| 617 |
-
}
|
| 618 |
-
|
| 619 |
-
.login-card img {
|
| 620 |
-
width: 64px;
|
| 621 |
-
margin-bottom: 16px;
|
| 622 |
-
}
|
| 623 |
-
|
| 624 |
-
.login-card h1 {
|
| 625 |
-
font-size: 20px;
|
| 626 |
-
margin-bottom: 4px;
|
| 627 |
-
}
|
| 628 |
-
|
| 629 |
-
.login-card p {
|
| 630 |
-
font-size: 13px;
|
| 631 |
-
margin-bottom: 20px;
|
| 632 |
-
}
|
| 633 |
-
|
| 634 |
-
.login-card input {
|
| 635 |
-
padding: 12px 14px;
|
| 636 |
-
font-size: 14px;
|
| 637 |
-
margin-bottom: 10px;
|
| 638 |
-
}
|
| 639 |
-
|
| 640 |
-
.login-card button {
|
| 641 |
-
padding: 12px;
|
| 642 |
-
font-size: 14px;
|
| 643 |
-
}
|
| 644 |
-
|
| 645 |
-
.login-card button svg {
|
| 646 |
-
width: 18px;
|
| 647 |
-
height: 18px;
|
| 648 |
-
}
|
| 649 |
-
|
| 650 |
-
.panel {
|
| 651 |
-
border-radius: var(--radius-sm);
|
| 652 |
-
margin-bottom: 12px;
|
| 653 |
-
}
|
| 654 |
-
|
| 655 |
-
.panel-header {
|
| 656 |
-
padding: 14px 16px;
|
| 657 |
-
font-size: 14px;
|
| 658 |
-
}
|
| 659 |
-
|
| 660 |
-
.panel-header h3 {
|
| 661 |
-
font-size: 14px;
|
| 662 |
-
}
|
| 663 |
-
|
| 664 |
-
.server-row {
|
| 665 |
-
flex-direction: column;
|
| 666 |
-
align-items: flex-start;
|
| 667 |
-
padding: 12px;
|
| 668 |
-
gap: 8px;
|
| 669 |
-
border-radius: var(--radius-sm);
|
| 670 |
-
background: var(--surface2);
|
| 671 |
-
margin: 8px;
|
| 672 |
-
}
|
| 673 |
-
|
| 674 |
-
.server-row:last-child {
|
| 675 |
-
border-bottom: none;
|
| 676 |
-
}
|
| 677 |
-
|
| 678 |
-
.server-row:hover {
|
| 679 |
-
background: var(--surface2);
|
| 680 |
-
}
|
| 681 |
-
|
| 682 |
-
.server-info {
|
| 683 |
-
width: 100%;
|
| 684 |
-
flex-direction: column;
|
| 685 |
-
gap: 6px;
|
| 686 |
-
}
|
| 687 |
-
|
| 688 |
-
.server-icon {
|
| 689 |
-
width: 36px;
|
| 690 |
-
height: 36px;
|
| 691 |
-
font-size: 14px;
|
| 692 |
-
}
|
| 693 |
-
|
| 694 |
-
.server-name {
|
| 695 |
-
font-size: 13px;
|
| 696 |
-
font-weight: 600;
|
| 697 |
-
}
|
| 698 |
-
|
| 699 |
-
.server-members {
|
| 700 |
-
font-size: 11px;
|
| 701 |
-
}
|
| 702 |
-
|
| 703 |
-
.server-rank {
|
| 704 |
-
font-size: 12px;
|
| 705 |
-
min-width: auto;
|
| 706 |
-
}
|
| 707 |
-
|
| 708 |
-
.member-badge {
|
| 709 |
-
padding: 4px 10px;
|
| 710 |
-
font-size: 11px;
|
| 711 |
-
}
|
| 712 |
-
|
| 713 |
-
.cmd-row {
|
| 714 |
-
flex-direction: column;
|
| 715 |
-
align-items: flex-start;
|
| 716 |
-
padding: 12px;
|
| 717 |
-
gap: 6px;
|
| 718 |
-
}
|
| 719 |
-
|
| 720 |
-
.cmd-row:hover {
|
| 721 |
-
background: var(--surface2);
|
| 722 |
-
}
|
| 723 |
-
|
| 724 |
-
.cmd-name {
|
| 725 |
-
font-size: 13px;
|
| 726 |
-
}
|
| 727 |
-
|
| 728 |
-
.cmd-desc {
|
| 729 |
-
font-size: 11px;
|
| 730 |
-
}
|
| 731 |
-
|
| 732 |
-
.cmd-badge {
|
| 733 |
-
padding: 3px 8px;
|
| 734 |
-
font-size: 10px;
|
| 735 |
-
}
|
| 736 |
-
|
| 737 |
-
.actions-grid {
|
| 738 |
-
grid-template-columns: 1fr;
|
| 739 |
-
padding: 12px;
|
| 740 |
-
gap: 10px;
|
| 741 |
-
}
|
| 742 |
-
|
| 743 |
-
.action-card {
|
| 744 |
-
padding: 16px;
|
| 745 |
-
border-radius: var(--radius-sm);
|
| 746 |
-
}
|
| 747 |
-
|
| 748 |
-
.action-card h4 {
|
| 749 |
-
font-size: 13px;
|
| 750 |
-
}
|
| 751 |
-
|
| 752 |
-
.action-card p {
|
| 753 |
-
font-size: 11px;
|
| 754 |
-
}
|
| 755 |
-
|
| 756 |
-
.action-icon {
|
| 757 |
-
font-size: 20px;
|
| 758 |
-
}
|
| 759 |
-
|
| 760 |
-
.invite-box {
|
| 761 |
-
padding: 24px 16px;
|
| 762 |
-
border-radius: var(--radius-sm);
|
| 763 |
-
margin-bottom: 16px;
|
| 764 |
-
}
|
| 765 |
-
|
| 766 |
-
.invite-box h3 {
|
| 767 |
-
font-size: 18px;
|
| 768 |
-
margin-bottom: 8px;
|
| 769 |
-
}
|
| 770 |
-
|
| 771 |
-
.invite-box p {
|
| 772 |
-
font-size: 13px;
|
| 773 |
-
margin-bottom: 16px;
|
| 774 |
-
}
|
| 775 |
-
|
| 776 |
-
.invite-btn {
|
| 777 |
-
padding: 12px 24px;
|
| 778 |
-
font-size: 13px;
|
| 779 |
-
width: 100%;
|
| 780 |
-
}
|
| 781 |
-
|
| 782 |
-
.log-area {
|
| 783 |
-
padding: 12px 14px;
|
| 784 |
-
font-size: 11px;
|
| 785 |
-
max-height: 300px;
|
| 786 |
-
}
|
| 787 |
-
|
| 788 |
-
.nav-item {
|
| 789 |
-
padding: 10px 12px;
|
| 790 |
-
font-size: 13px;
|
| 791 |
-
gap: 10px;
|
| 792 |
-
}
|
| 793 |
-
|
| 794 |
-
.nav-item svg {
|
| 795 |
-
width: 18px;
|
| 796 |
-
height: 18px;
|
| 797 |
-
}
|
| 798 |
-
|
| 799 |
-
.switch {
|
| 800 |
-
width: 44px;
|
| 801 |
-
height: 22px;
|
| 802 |
-
}
|
| 803 |
-
|
| 804 |
-
.slider:before {
|
| 805 |
-
height: 16px;
|
| 806 |
-
width: 16px;
|
| 807 |
-
}
|
| 808 |
-
|
| 809 |
-
input:checked + .slider:before {
|
| 810 |
-
transform: translateX(22px);
|
| 811 |
-
}
|
| 812 |
-
}
|
| 813 |
-
|
| 814 |
-
/* Ultra-small devices (480px and below) */
|
| 815 |
-
@media (max-width: 480px) {
|
| 816 |
-
.login-card {
|
| 817 |
-
width: 98vw;
|
| 818 |
-
padding: 24px 16px;
|
| 819 |
-
}
|
| 820 |
-
|
| 821 |
-
.stat-card {
|
| 822 |
-
min-height: 80px;
|
| 823 |
-
display: flex;
|
| 824 |
-
flex-direction: column;
|
| 825 |
-
justify-content: center;
|
| 826 |
-
}
|
| 827 |
-
|
| 828 |
-
.stats-grid {
|
| 829 |
-
grid-template-columns: repeat(2, 1fr);
|
| 830 |
-
gap: 8px;
|
| 831 |
-
}
|
| 832 |
-
|
| 833 |
-
.topbar h2 {
|
| 834 |
-
font-size: 18px;
|
| 835 |
-
}
|
| 836 |
-
|
| 837 |
-
.server-row,
|
| 838 |
-
.cmd-row {
|
| 839 |
-
margin: 6px;
|
| 840 |
-
padding: 10px;
|
| 841 |
-
}
|
| 842 |
-
|
| 843 |
-
.actions-grid {
|
| 844 |
-
padding: 8px;
|
| 845 |
-
}
|
| 846 |
-
|
| 847 |
-
.panel-header {
|
| 848 |
-
padding: 12px;
|
| 849 |
-
}
|
| 850 |
-
|
| 851 |
-
.main {
|
| 852 |
-
padding: 12px 8px;
|
| 853 |
-
}
|
| 854 |
}
|
| 855 |
|
| 856 |
/* Scrollbar */
|
|
@@ -908,35 +411,6 @@ input:checked + .slider {
|
|
| 908 |
input:checked + .slider:before {
|
| 909 |
transform: translateX(24px);
|
| 910 |
}
|
| 911 |
-
|
| 912 |
-
/* Refresh Button */
|
| 913 |
-
.refresh-btn {
|
| 914 |
-
background: var(--surface2);
|
| 915 |
-
border: 1px solid var(--border);
|
| 916 |
-
color: var(--text-mid);
|
| 917 |
-
padding: 8px;
|
| 918 |
-
border-radius: var(--radius-sm);
|
| 919 |
-
cursor: pointer;
|
| 920 |
-
transition: all 0.2s;
|
| 921 |
-
display: flex;
|
| 922 |
-
align-items: center;
|
| 923 |
-
justify-content: center;
|
| 924 |
-
margin-right: 8px;
|
| 925 |
-
}
|
| 926 |
-
.refresh-btn:hover {
|
| 927 |
-
color: var(--text);
|
| 928 |
-
border-color: var(--accent);
|
| 929 |
-
background: var(--surface);
|
| 930 |
-
transform: translateY(-1px);
|
| 931 |
-
}
|
| 932 |
-
.refresh-btn svg { width: 18px; height: 18px; }
|
| 933 |
-
.refresh-btn.loading svg {
|
| 934 |
-
animation: spin 0.8s linear infinite;
|
| 935 |
-
}
|
| 936 |
-
@keyframes spin {
|
| 937 |
-
from { transform: rotate(0deg); }
|
| 938 |
-
to { transform: rotate(360deg); }
|
| 939 |
-
}
|
| 940 |
</style>
|
| 941 |
</head>
|
| 942 |
<body>
|
|
@@ -948,7 +422,7 @@ input:checked + .slider:before {
|
|
| 948 |
<h1>FriendlyBot</h1>
|
| 949 |
<p>Sign in with your Discord account to access the dashboard</p>
|
| 950 |
<button onclick="window.location.href='/auth/login'">
|
| 951 |
-
<svg viewBox="0 0 24 24" fill="currentColor"><path d="
|
| 952 |
Login with Discord
|
| 953 |
</button>
|
| 954 |
<div class="login-error" id="login-error"></div>
|
|
@@ -959,39 +433,35 @@ input:checked + .slider:before {
|
|
| 959 |
<!-- ===== DASHBOARD ===== -->
|
| 960 |
<div id="dashboard">
|
| 961 |
<!-- Sidebar -->
|
| 962 |
-
<div class="sidebar"
|
| 963 |
<div class="sidebar-brand">
|
| 964 |
<img src="/logo.png" alt="">
|
| 965 |
<span>FriendlyBot</span>
|
| 966 |
-
<button class="mobile-menu-toggle" onclick="toggleMobileMenu()" id="mobile-menu-toggle" title="Toggle Menu" style="display:none;">
|
| 967 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>
|
| 968 |
-
</button>
|
| 969 |
</div>
|
| 970 |
<div class="sidebar-nav">
|
| 971 |
-
<div class="nav-item active" onclick="showPage('overview', this)
|
| 972 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>
|
| 973 |
Overview
|
| 974 |
</div>
|
| 975 |
-
<div class="nav-item" onclick="showPage('servers', this)
|
| 976 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>
|
| 977 |
Servers
|
| 978 |
</div>
|
| 979 |
-
<div class="nav-item" onclick="showPage('commands', this)
|
| 980 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>
|
| 981 |
Commands
|
| 982 |
</div>
|
| 983 |
-
<div class="nav-item" onclick="showPage('invite', this)
|
| 984 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>
|
| 985 |
Invite Bot
|
| 986 |
</div>
|
| 987 |
-
<div class="nav-item" onclick="showPage('
|
| 988 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><
|
| 989 |
-
|
| 990 |
</div>
|
| 991 |
</div>
|
| 992 |
-
</div>
|
| 993 |
<div class="sidebar-footer">
|
| 994 |
-
<div class="nav-item" onclick="logout()
|
| 995 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
| 996 |
Sign Out
|
| 997 |
</div>
|
|
@@ -1005,9 +475,6 @@ input:checked + .slider:before {
|
|
| 1005 |
<div class="topbar">
|
| 1006 |
<h2>Dashboard</h2>
|
| 1007 |
<div class="topbar-right">
|
| 1008 |
-
<button class="refresh-btn" onclick="refreshAll()" title="Refresh Data">
|
| 1009 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>
|
| 1010 |
-
</button>
|
| 1011 |
<div class="user-pill" id="user-pill" style="display:none">
|
| 1012 |
<img id="user-avatar" src="" alt="">
|
| 1013 |
<span id="user-name"></span>
|
|
@@ -1042,11 +509,26 @@ input:checked + .slider:before {
|
|
| 1042 |
<div class="panel">
|
| 1043 |
<div class="panel-header"><h3>⚡ Quick Actions</h3></div>
|
| 1044 |
<div class="actions-grid">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1045 |
<div class="action-card" onclick="window.open('/api/invite','_blank')">
|
| 1046 |
<div class="action-icon">🤖</div>
|
| 1047 |
<h4>Add to Server</h4>
|
| 1048 |
<p>Generate a fresh invite link and add the bot to a new server.</p>
|
| 1049 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1050 |
</div>
|
| 1051 |
</div>
|
| 1052 |
</div>
|
|
@@ -1116,83 +598,13 @@ input:checked + .slider:before {
|
|
| 1116 |
</div>
|
| 1117 |
</div>
|
| 1118 |
|
| 1119 |
-
<!-- =====
|
| 1120 |
-
<div class="page" id="page-
|
| 1121 |
-
<div class="topbar">
|
| 1122 |
-
|
| 1123 |
-
<div class="
|
| 1124 |
-
|
| 1125 |
-
|
| 1126 |
-
</div>
|
| 1127 |
-
</div>
|
| 1128 |
-
</div>
|
| 1129 |
-
|
| 1130 |
-
<div id="premium-content">
|
| 1131 |
-
<div class="panel" id="premium-hero" style="background:linear-gradient(135deg, #FFD700 0%, #FFA500 100%); color:#000; text-align:center; padding:30px;">
|
| 1132 |
-
<h3 style="font-size:22px; font-weight:800; margin-bottom:10px;">⭐ FriendlyBot Premium</h3>
|
| 1133 |
-
<p style="opacity:0.8; margin-bottom:0;">Unlock exclusive features by winning a league match. Premium is granted automatically when you record a win with <code style="background:rgba(0,0,0,0.1); padding:2px 8px; border-radius:4px;">!win</code>.</p>
|
| 1134 |
-
</div>
|
| 1135 |
-
|
| 1136 |
-
<div class="stats-grid" id="premium-features">
|
| 1137 |
-
<div class="stat-card premium-locked" data-premium="0">
|
| 1138 |
-
<div class="label">📊 Advanced Stats & Analytics</div>
|
| 1139 |
-
<div class="sub">Track goals, assists, clean sheets, and weekly leaderboards for every player.</div>
|
| 1140 |
-
</div>
|
| 1141 |
-
<div class="stat-card premium-locked" data-premium="1">
|
| 1142 |
-
<div class="label">📅 Match Scheduling & Reminders</div>
|
| 1143 |
-
<div class="sub">Auto-post scheduled matches with DM reminders before kickoff.</div>
|
| 1144 |
-
</div>
|
| 1145 |
-
<div class="stat-card premium-locked" data-premium="2">
|
| 1146 |
-
<div class="label">🎴 Player Profile Cards</div>
|
| 1147 |
-
<div class="sub">Advanced profile images with extra stats and custom backgrounds.</div>
|
| 1148 |
-
</div>
|
| 1149 |
-
<div class="stat-card premium-locked" data-premium="3">
|
| 1150 |
-
<div class="label">🔧 Custom Command Aliases</div>
|
| 1151 |
-
<div class="sub">Rename bot commands to fit your server.</div>
|
| 1152 |
-
</div>
|
| 1153 |
-
</div>
|
| 1154 |
-
|
| 1155 |
-
<!-- Premium Config Panel (only visible if premium) -->
|
| 1156 |
-
<div class="panel" id="premium-config-panel" style="display:none;">
|
| 1157 |
-
<div class="panel-header"><h3>⚙️ Premium Settings</h3></div>
|
| 1158 |
-
<div class="panel-body" style="padding:24px;">
|
| 1159 |
-
<div style="margin-bottom:32px;">
|
| 1160 |
-
<h4 style="margin-bottom:16px; font-size:15px; color:var(--gold);">📅 Match Reminders</h4>
|
| 1161 |
-
<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap:24px">
|
| 1162 |
-
<div>
|
| 1163 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">DM Reminders</label>
|
| 1164 |
-
<div style="display:flex; align-items:center; gap:12px">
|
| 1165 |
-
<label class="switch">
|
| 1166 |
-
<input type="checkbox" id="config-premium-reminders">
|
| 1167 |
-
<span class="slider"></span>
|
| 1168 |
-
</label>
|
| 1169 |
-
<span style="font-size:14px; color:var(--text-mid)">Enabled</span>
|
| 1170 |
-
</div>
|
| 1171 |
-
</div>
|
| 1172 |
-
<div>
|
| 1173 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Reminder Timer (Minutes)</label>
|
| 1174 |
-
<input type="number" id="config-premium-reminder-timer" placeholder="60" min="5" max="1440" style="width:100%; padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:white; font-size:16px; outline:none">
|
| 1175 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:6px">Players will be DM'd this many minutes before a scheduled league match.</p>
|
| 1176 |
-
</div>
|
| 1177 |
-
<div>
|
| 1178 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Current Timer</label>
|
| 1179 |
-
<div style="padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm);">
|
| 1180 |
-
<span id="premium-timer-display" style="font-size:16px; font-weight:700; color:var(--text);">—</span>
|
| 1181 |
-
</div>
|
| 1182 |
-
</div>
|
| 1183 |
-
</div>
|
| 1184 |
-
</div>
|
| 1185 |
-
<div style="border-top:1px solid var(--border); padding-top:24px; text-align:right">
|
| 1186 |
-
<button class="invite-btn" onclick="savePremiumConfig()" style="background:var(--gold); color:#000; padding:12px 32px; font-weight:800;">Save Premium Settings</button>
|
| 1187 |
-
</div>
|
| 1188 |
-
</div>
|
| 1189 |
-
</div>
|
| 1190 |
-
|
| 1191 |
-
<div class="panel">
|
| 1192 |
-
<div class="panel-header"><h3>🏆 Premium Users</h3></div>
|
| 1193 |
-
<div class="panel-body" id="premium-users-list" style="padding:24px;">
|
| 1194 |
-
<p style="color:var(--text-dim)">Loading...</p>
|
| 1195 |
-
</div>
|
| 1196 |
</div>
|
| 1197 |
</div>
|
| 1198 |
</div>
|
|
@@ -1265,63 +677,6 @@ input:checked + .slider:before {
|
|
| 1265 |
<p style="font-size:12px; color:var(--text-dim); margin-top:16px">Control where global announcements from the bot owner are posted. You can opt-out by disabling this feature.</p>
|
| 1266 |
</div>
|
| 1267 |
|
| 1268 |
-
<div style="border-top:1px solid var(--border); padding-top:32px; margin-bottom: 32px;">
|
| 1269 |
-
<h4 style="margin-bottom:16px; font-size:15px; color:var(--accent)">🧹 Auto Cleanup & Maintenance</h4>
|
| 1270 |
-
<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap:24px">
|
| 1271 |
-
<div>
|
| 1272 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Poll Cleanup (Hours)</label>
|
| 1273 |
-
<input type="number" id="config-cleanup-hours" placeholder="2" style="width:100%; padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:white; outline:none">
|
| 1274 |
-
</div>
|
| 1275 |
-
<div>
|
| 1276 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Lineup Cleanup (Hours)</label>
|
| 1277 |
-
<input type="number" id="config-lineup-cleanup-hours" placeholder="2" style="width:100%; padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:white; outline:none">
|
| 1278 |
-
</div>
|
| 1279 |
-
</div>
|
| 1280 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:16px">The bot will automatically delete friendly polls and lineup boards after the specified time to keep channels clean.</p>
|
| 1281 |
-
</div>
|
| 1282 |
-
|
| 1283 |
-
<div style="border-top:1px solid var(--border); padding-top:32px; margin-bottom: 32px;">
|
| 1284 |
-
<h4 style="margin-bottom:16px; font-size:15px; color:var(--accent)">⏰ Match Reminders</h4>
|
| 1285 |
-
<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap:24px">
|
| 1286 |
-
<div>
|
| 1287 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Enable DM Reminders</label>
|
| 1288 |
-
<div style="display:flex; align-items:center; gap:12px">
|
| 1289 |
-
<label class="switch">
|
| 1290 |
-
<input type="checkbox" id="config-reminders-enabled">
|
| 1291 |
-
<span class="slider"></span>
|
| 1292 |
-
</label>
|
| 1293 |
-
<span style="font-size:14px; color:var(--text-mid)">Enabled</span>
|
| 1294 |
-
</div>
|
| 1295 |
-
</div>
|
| 1296 |
-
<div>
|
| 1297 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Lead Time (Minutes)</label>
|
| 1298 |
-
<input type="number" id="config-reminders-lead" placeholder="30" style="width:100%; padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:white; outline:none">
|
| 1299 |
-
</div>
|
| 1300 |
-
</div>
|
| 1301 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:16px">When enabled, players on the lineup board will receive a DM reminder before a scheduled league match starts.</p>
|
| 1302 |
-
</div>
|
| 1303 |
-
|
| 1304 |
-
<div style="border-top:1px solid var(--border); padding-top:32px; margin-bottom: 32px;">
|
| 1305 |
-
<h4 style="margin-bottom:16px; font-size:15px; color:var(--accent)">🔐 Staff Whitelist Roles</h4>
|
| 1306 |
-
<div style="margin-bottom: 24px;">
|
| 1307 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Permitted Whitelisted Roles</label>
|
| 1308 |
-
<div id="whitelist-roles-container" style="display: flex; flex-wrap: wrap; gap: 12px; max-height: 200px; overflow-y: auto; padding: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);">
|
| 1309 |
-
<span style="font-size:13px; color:var(--text-dim);">Loading server roles...</span>
|
| 1310 |
-
</div>
|
| 1311 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">Members with any of the checked roles will be permitted to run staff/manager commands (e.g. <code>!friendly</code>, <code>!lineup</code>, <code>!win</code>, <code>!loss</code>, <code>!draw</code>, <code>!motm</code>).</p>
|
| 1312 |
-
</div>
|
| 1313 |
-
</div>
|
| 1314 |
-
|
| 1315 |
-
<div style="border-top:1px solid var(--border); padding-top:32px; margin-bottom: 32px;">
|
| 1316 |
-
<h4 style="margin-bottom:16px; font-size:15px; color:var(--accent)">💬 Command Messages</h4>
|
| 1317 |
-
<div style="margin-bottom: 24px;">
|
| 1318 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:8px">Friendly Command Text</label>
|
| 1319 |
-
<textarea id="config-friendly-text" oninput="autoResize(this)" style="width:100%; min-height:100px; padding:12px; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:white; font-family:monospace; font-size:13px; outline:none; resize:none; overflow:hidden; transition: height 0.2s ease;"></textarea>
|
| 1320 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">Use <code>{needed}</code> as a placeholder for the number of players needed.</p>
|
| 1321 |
-
</div>
|
| 1322 |
-
|
| 1323 |
-
</div>
|
| 1324 |
-
|
| 1325 |
<div style="border-top:1px solid var(--border); padding-top:24px; text-align:right">
|
| 1326 |
<button class="invite-btn" onclick="saveConfig()" style="background:var(--accent); color:white; padding:12px 32px">Save All Changes</button>
|
| 1327 |
</div>
|
|
@@ -1377,40 +732,9 @@ function showDashboard() {
|
|
| 1377 |
loadServers();
|
| 1378 |
loadCommands();
|
| 1379 |
loadLogs();
|
| 1380 |
-
|
| 1381 |
-
|
| 1382 |
-
|
| 1383 |
-
setInterval(loadStats, 15000);
|
| 1384 |
-
setInterval(loadServers, 15000);
|
| 1385 |
-
setInterval(loadLogs, 10000);
|
| 1386 |
-
|
| 1387 |
-
// Auto-refresh when tab becomes visible or focused
|
| 1388 |
-
// This solves the issue of not seeing a server after adding it
|
| 1389 |
-
window.addEventListener('focus', () => {
|
| 1390 |
-
console.log("Tab focused, refreshing dashboard data...");
|
| 1391 |
-
refreshAll();
|
| 1392 |
-
});
|
| 1393 |
-
|
| 1394 |
-
document.addEventListener('visibilitychange', () => {
|
| 1395 |
-
if (document.visibilityState === 'visible') {
|
| 1396 |
-
refreshAll();
|
| 1397 |
-
}
|
| 1398 |
-
});
|
| 1399 |
-
}
|
| 1400 |
-
|
| 1401 |
-
function refreshAll() {
|
| 1402 |
-
const btn = document.querySelector('.refresh-btn');
|
| 1403 |
-
if (btn) btn.classList.add('loading');
|
| 1404 |
-
|
| 1405 |
-
return Promise.all([
|
| 1406 |
-
loadStats(),
|
| 1407 |
-
loadServers(),
|
| 1408 |
-
loadLogs()
|
| 1409 |
-
]).finally(() => {
|
| 1410 |
-
setTimeout(() => {
|
| 1411 |
-
if (btn) btn.classList.remove('loading');
|
| 1412 |
-
}, 600);
|
| 1413 |
-
});
|
| 1414 |
}
|
| 1415 |
|
| 1416 |
function logout() {
|
|
@@ -1427,7 +751,7 @@ function showPage(name, el) {
|
|
| 1427 |
|
| 1428 |
// ===== DATA LOADERS =====
|
| 1429 |
function loadStats() {
|
| 1430 |
-
|
| 1431 |
.then(r => r.json())
|
| 1432 |
.then(data => {
|
| 1433 |
document.getElementById('stat-servers').textContent = data.servers || 0;
|
|
@@ -1440,7 +764,7 @@ function loadStats() {
|
|
| 1440 |
}
|
| 1441 |
|
| 1442 |
function loadServers() {
|
| 1443 |
-
|
| 1444 |
.then(r => r.json())
|
| 1445 |
.then(data => {
|
| 1446 |
const servers = Array.isArray(data) ? data : (Array.isArray(data.servers) ? data.servers : []);
|
|
@@ -1495,19 +819,9 @@ function openServerSettings(id, name) {
|
|
| 1495 |
.then(r => r.json())
|
| 1496 |
.then(data => {
|
| 1497 |
document.getElementById('config-prefix').value = data.prefix || '!';
|
| 1498 |
-
document.getElementById('config-auto-enabled').checked =
|
| 1499 |
document.getElementById('config-auto-interval').value = data.autoFriendlyInterval || 40;
|
| 1500 |
document.getElementById('config-post-enabled').checked = data.postEnabled !== false;
|
| 1501 |
-
document.getElementById('config-friendly-text').value = data.friendlyText || "";
|
| 1502 |
-
|
| 1503 |
-
// Auto-resize the textarea after setting value
|
| 1504 |
-
const friendlyTextarea = document.getElementById('config-friendly-text');
|
| 1505 |
-
setTimeout(() => autoResize(friendlyTextarea), 50);
|
| 1506 |
-
|
| 1507 |
-
document.getElementById('config-cleanup-hours').value = data.cleanupHours || 2;
|
| 1508 |
-
document.getElementById('config-lineup-cleanup-hours').value = data.lineupCleanupHours || 2;
|
| 1509 |
-
document.getElementById('config-reminders-enabled').checked = !!data.remindersEnabled;
|
| 1510 |
-
document.getElementById('config-reminders-lead').value = data.remindersLead || 30;
|
| 1511 |
|
| 1512 |
// Load channels and set selected
|
| 1513 |
fetch('/api/channels/' + id)
|
|
@@ -1533,45 +847,6 @@ function openServerSettings(id, name) {
|
|
| 1533 |
postSelect.appendChild(optP);
|
| 1534 |
});
|
| 1535 |
});
|
| 1536 |
-
|
| 1537 |
-
// Load roles and build whitelisted checklist
|
| 1538 |
-
fetch('/api/roles/' + id)
|
| 1539 |
-
.then(rr => rr.json())
|
| 1540 |
-
.then(roles => {
|
| 1541 |
-
const rolesContainer = document.getElementById('whitelist-roles-container');
|
| 1542 |
-
rolesContainer.innerHTML = '';
|
| 1543 |
-
|
| 1544 |
-
if (!roles || roles.length === 0) {
|
| 1545 |
-
rolesContainer.innerHTML = '<span style="font-size:13px; color:var(--text-dim);">No roles found or bot lacks permission to view roles.</span>';
|
| 1546 |
-
return;
|
| 1547 |
-
}
|
| 1548 |
-
|
| 1549 |
-
roles.forEach(role => {
|
| 1550 |
-
const div = document.createElement('div');
|
| 1551 |
-
div.style.cssText = 'display: flex; align-items: center; gap: 8px; margin-right: 16px; margin-bottom: 8px; user-select: none;';
|
| 1552 |
-
|
| 1553 |
-
const chk = document.createElement('input');
|
| 1554 |
-
chk.type = 'checkbox';
|
| 1555 |
-
chk.className = 'role-whitelist-chk';
|
| 1556 |
-
chk.value = role.id;
|
| 1557 |
-
chk.id = 'role-chk-' + role.id;
|
| 1558 |
-
|
| 1559 |
-
if (data.whitelistedRoles && data.whitelistedRoles.includes(role.id)) {
|
| 1560 |
-
chk.checked = true;
|
| 1561 |
-
}
|
| 1562 |
-
|
| 1563 |
-
const lbl = document.createElement('label');
|
| 1564 |
-
lbl.htmlFor = 'role-chk-' + role.id;
|
| 1565 |
-
lbl.style.cssText = `font-size: 14px; color: ${role.color || '#ffffff'}; cursor: pointer;`;
|
| 1566 |
-
lbl.textContent = role.name;
|
| 1567 |
-
|
| 1568 |
-
div.appendChild(chk);
|
| 1569 |
-
div.appendChild(lbl);
|
| 1570 |
-
rolesContainer.appendChild(div);
|
| 1571 |
-
});
|
| 1572 |
-
}).catch(() => {
|
| 1573 |
-
document.getElementById('whitelist-roles-container').innerHTML = '<span style="font-size:13px; color:var(--text-dim); color:#ff4444">Error loading server roles.</span>';
|
| 1574 |
-
});
|
| 1575 |
});
|
| 1576 |
}
|
| 1577 |
|
|
@@ -1583,14 +858,6 @@ function saveConfig() {
|
|
| 1583 |
const autoFriendlyChannel = document.getElementById('config-auto-channel').value;
|
| 1584 |
const postEnabled = document.getElementById('config-post-enabled').checked;
|
| 1585 |
const postChannelId = document.getElementById('config-post-channel').value;
|
| 1586 |
-
const friendlyText = document.getElementById('config-friendly-text').value;
|
| 1587 |
-
|
| 1588 |
-
const cleanupHours = document.getElementById('config-cleanup-hours').value;
|
| 1589 |
-
const lineupCleanupHours = document.getElementById('config-lineup-cleanup-hours').value;
|
| 1590 |
-
const remindersEnabled = document.getElementById('config-reminders-enabled').checked;
|
| 1591 |
-
const remindersLead = document.getElementById('config-reminders-lead').value;
|
| 1592 |
-
|
| 1593 |
-
const whitelistedRoles = Array.from(document.querySelectorAll('.role-whitelist-chk:checked')).map(el => el.value);
|
| 1594 |
|
| 1595 |
fetch('/api/config/' + activeGuildId, {
|
| 1596 |
method: 'POST',
|
|
@@ -1601,13 +868,7 @@ function saveConfig() {
|
|
| 1601 |
autoFriendlyInterval,
|
| 1602 |
autoFriendlyChannel,
|
| 1603 |
postEnabled,
|
| 1604 |
-
postChannelId
|
| 1605 |
-
friendlyText,
|
| 1606 |
-
cleanupHours,
|
| 1607 |
-
lineupCleanupHours,
|
| 1608 |
-
remindersEnabled,
|
| 1609 |
-
remindersLead,
|
| 1610 |
-
whitelistedRoles
|
| 1611 |
})
|
| 1612 |
})
|
| 1613 |
.then(r => r.json())
|
|
@@ -1621,7 +882,7 @@ function saveConfig() {
|
|
| 1621 |
}
|
| 1622 |
|
| 1623 |
function loadCommands() {
|
| 1624 |
-
|
| 1625 |
.then(r => r.json())
|
| 1626 |
.then(data => {
|
| 1627 |
const container = document.getElementById('command-list');
|
|
@@ -1643,7 +904,7 @@ function loadCommands() {
|
|
| 1643 |
}
|
| 1644 |
|
| 1645 |
function loadLogs() {
|
| 1646 |
-
|
| 1647 |
.then(r => r.json())
|
| 1648 |
.then(data => {
|
| 1649 |
const area = document.getElementById('log-area');
|
|
@@ -1671,102 +932,6 @@ function escapeHtml(str) {
|
|
| 1671 |
d.textContent = str;
|
| 1672 |
return d.innerHTML;
|
| 1673 |
}
|
| 1674 |
-
|
| 1675 |
-
function autoResize(el) {
|
| 1676 |
-
el.style.height = 'auto';
|
| 1677 |
-
el.style.height = el.scrollHeight + 'px';
|
| 1678 |
-
}
|
| 1679 |
-
|
| 1680 |
-
async function loadPremium() {
|
| 1681 |
-
const statusEl = document.getElementById('premium-status-badge');
|
| 1682 |
-
const cards = document.querySelectorAll('#premium-features .stat-card');
|
| 1683 |
-
const listEl = document.getElementById('premium-users-list');
|
| 1684 |
-
|
| 1685 |
-
try {
|
| 1686 |
-
const r = await fetch('/api/premium');
|
| 1687 |
-
const data = await r.json();
|
| 1688 |
-
|
| 1689 |
-
if (data.premium) {
|
| 1690 |
-
statusEl.innerHTML = '<div class="status-dot" style="background:var(--gold);"></div> ACTIVE';
|
| 1691 |
-
statusEl.style.color = 'var(--gold)';
|
| 1692 |
-
cards.forEach(c => {
|
| 1693 |
-
c.classList.remove('premium-locked');
|
| 1694 |
-
c.classList.add('premium-unlocked');
|
| 1695 |
-
c.style.cursor = 'pointer';
|
| 1696 |
-
|
| 1697 |
-
const feature = c.getAttribute('data-premium');
|
| 1698 |
-
c.onclick = () => {
|
| 1699 |
-
if (feature === '0') window.location.href = '/stats';
|
| 1700 |
-
else if (feature === '1') window.location.href = '/scheduling';
|
| 1701 |
-
else if (feature === '2') window.location.href = '/profiles';
|
| 1702 |
-
else if (feature === '3') window.location.href = '/aliases';
|
| 1703 |
-
};
|
| 1704 |
-
});
|
| 1705 |
-
} else {
|
| 1706 |
-
statusEl.innerHTML = '<div class="status-dot" style="background:var(--text-dim);"></div> LOCKED';
|
| 1707 |
-
statusEl.style.color = 'var(--text-dim)';
|
| 1708 |
-
}
|
| 1709 |
-
|
| 1710 |
-
const listR = await fetch('/api/premium/list');
|
| 1711 |
-
const listData = await listR.json();
|
| 1712 |
-
if (listData.list && listData.list.length > 0) {
|
| 1713 |
-
listEl.innerHTML = listData.list.map(u => `
|
| 1714 |
-
<div style="display:flex; justify-content:space-between; align-items:center; padding:12px; border-bottom:1px solid var(--border)">
|
| 1715 |
-
<div style="display:flex; align-items:center; gap:10px">
|
| 1716 |
-
<img src="${u.avatarUrl || '/logo.png'}" style="width:24px; height:24px; border-radius:50%">
|
| 1717 |
-
<span style="font-size:14px">${u.userTag}</span>
|
| 1718 |
-
</div>
|
| 1719 |
-
<span style="font-size:12px; color:var(--text-dim)">${new Date(u.grantedAt).toLocaleDateString()}</span>
|
| 1720 |
-
</div>
|
| 1721 |
-
`).join('');
|
| 1722 |
-
}
|
| 1723 |
-
} catch (e) {}
|
| 1724 |
-
}
|
| 1725 |
-
|
| 1726 |
-
// Mobile Menu Toggle
|
| 1727 |
-
function toggleMobileMenu() {
|
| 1728 |
-
const sidebar = document.getElementById('sidebar');
|
| 1729 |
-
const main = document.querySelector('.main');
|
| 1730 |
-
sidebar.classList.toggle('mobile-open');
|
| 1731 |
-
main.classList.toggle('sidebar-mobile-open');
|
| 1732 |
-
}
|
| 1733 |
-
|
| 1734 |
-
function closeMobileMenu() {
|
| 1735 |
-
const sidebar = document.getElementById('sidebar');
|
| 1736 |
-
const main = document.querySelector('.main');
|
| 1737 |
-
if (window.innerWidth <= 600) {
|
| 1738 |
-
sidebar.classList.remove('mobile-open');
|
| 1739 |
-
main.classList.remove('sidebar-mobile-open');
|
| 1740 |
-
}
|
| 1741 |
-
}
|
| 1742 |
-
|
| 1743 |
-
function updateMobileMenuVisibility() {
|
| 1744 |
-
const toggle = document.getElementById('mobile-menu-toggle');
|
| 1745 |
-
if (window.innerWidth <= 600) {
|
| 1746 |
-
toggle.style.display = 'flex';
|
| 1747 |
-
} else {
|
| 1748 |
-
toggle.style.display = 'none';
|
| 1749 |
-
const sidebar = document.getElementById('sidebar');
|
| 1750 |
-
const main = document.querySelector('.main');
|
| 1751 |
-
sidebar.classList.remove('mobile-open');
|
| 1752 |
-
main.classList.remove('sidebar-mobile-open');
|
| 1753 |
-
}
|
| 1754 |
-
}
|
| 1755 |
-
|
| 1756 |
-
window.addEventListener('resize', updateMobileMenuVisibility);
|
| 1757 |
-
document.addEventListener('DOMContentLoaded', updateMobileMenuVisibility);
|
| 1758 |
-
|
| 1759 |
-
// Close mobile menu when clicking outside
|
| 1760 |
-
document.addEventListener('click', function(event) {
|
| 1761 |
-
const sidebar = document.getElementById('sidebar');
|
| 1762 |
-
const toggle = document.getElementById('mobile-menu-toggle');
|
| 1763 |
-
if (window.innerWidth <= 600 &&
|
| 1764 |
-
!sidebar.contains(event.target) &&
|
| 1765 |
-
!toggle.contains(event.target) &&
|
| 1766 |
-
sidebar.classList.contains('mobile-open')) {
|
| 1767 |
-
closeMobileMenu();
|
| 1768 |
-
}
|
| 1769 |
-
});
|
| 1770 |
</script>
|
| 1771 |
</body>
|
| 1772 |
</html>
|
|
|
|
| 24 |
--text-mid: rgba(255,255,255,0.7);
|
| 25 |
--radius: 16px;
|
| 26 |
--radius-sm: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
body {
|
|
|
|
| 350 |
.log-line.error { color: var(--red); }
|
| 351 |
.log-line.warn { color: var(--yellow); }
|
| 352 |
|
| 353 |
+
/* Responsive */
|
| 354 |
@media (max-width: 768px) {
|
| 355 |
+
.sidebar { display: none; }
|
| 356 |
+
.main { margin-left: 0; padding: 20px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
}
|
| 358 |
|
| 359 |
/* Scrollbar */
|
|
|
|
| 411 |
input:checked + .slider:before {
|
| 412 |
transform: translateX(24px);
|
| 413 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
</style>
|
| 415 |
</head>
|
| 416 |
<body>
|
|
|
|
| 422 |
<h1>FriendlyBot</h1>
|
| 423 |
<p>Sign in with your Discord account to access the dashboard</p>
|
| 424 |
<button onclick="window.location.href='/auth/login'">
|
| 425 |
+
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03z"/></svg>
|
| 426 |
Login with Discord
|
| 427 |
</button>
|
| 428 |
<div class="login-error" id="login-error"></div>
|
|
|
|
| 433 |
<!-- ===== DASHBOARD ===== -->
|
| 434 |
<div id="dashboard">
|
| 435 |
<!-- Sidebar -->
|
| 436 |
+
<div class="sidebar">
|
| 437 |
<div class="sidebar-brand">
|
| 438 |
<img src="/logo.png" alt="">
|
| 439 |
<span>FriendlyBot</span>
|
|
|
|
|
|
|
|
|
|
| 440 |
</div>
|
| 441 |
<div class="sidebar-nav">
|
| 442 |
+
<div class="nav-item active" onclick="showPage('overview', this)">
|
| 443 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>
|
| 444 |
Overview
|
| 445 |
</div>
|
| 446 |
+
<div class="nav-item" onclick="showPage('servers', this)">
|
| 447 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>
|
| 448 |
Servers
|
| 449 |
</div>
|
| 450 |
+
<div class="nav-item" onclick="showPage('commands', this)">
|
| 451 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>
|
| 452 |
Commands
|
| 453 |
</div>
|
| 454 |
+
<div class="nav-item" onclick="showPage('invite', this)">
|
| 455 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>
|
| 456 |
Invite Bot
|
| 457 |
</div>
|
| 458 |
+
<div class="nav-item" onclick="showPage('logs', this)">
|
| 459 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
|
| 460 |
+
Logs
|
| 461 |
</div>
|
| 462 |
</div>
|
|
|
|
| 463 |
<div class="sidebar-footer">
|
| 464 |
+
<div class="nav-item" onclick="logout()">
|
| 465 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
| 466 |
Sign Out
|
| 467 |
</div>
|
|
|
|
| 475 |
<div class="topbar">
|
| 476 |
<h2>Dashboard</h2>
|
| 477 |
<div class="topbar-right">
|
|
|
|
|
|
|
|
|
|
| 478 |
<div class="user-pill" id="user-pill" style="display:none">
|
| 479 |
<img id="user-avatar" src="" alt="">
|
| 480 |
<span id="user-name"></span>
|
|
|
|
| 509 |
<div class="panel">
|
| 510 |
<div class="panel-header"><h3>⚡ Quick Actions</h3></div>
|
| 511 |
<div class="actions-grid">
|
| 512 |
+
<div class="action-card" onclick="triggerAction('sync')">
|
| 513 |
+
<div class="action-icon">🔄</div>
|
| 514 |
+
<h4>Sync Commands</h4>
|
| 515 |
+
<p>Force-sync all slash commands to every server immediately.</p>
|
| 516 |
+
</div>
|
| 517 |
+
<div class="action-card" onclick="triggerAction('backup')">
|
| 518 |
+
<div class="action-icon">☁️</div>
|
| 519 |
+
<h4>Cloud Backup</h4>
|
| 520 |
+
<p>Trigger an immediate backup of all bot data to Discord.</p>
|
| 521 |
+
</div>
|
| 522 |
<div class="action-card" onclick="window.open('/api/invite','_blank')">
|
| 523 |
<div class="action-icon">🤖</div>
|
| 524 |
<h4>Add to Server</h4>
|
| 525 |
<p>Generate a fresh invite link and add the bot to a new server.</p>
|
| 526 |
</div>
|
| 527 |
+
<div class="action-card" onclick="triggerAction('restart')">
|
| 528 |
+
<div class="action-icon">🔁</div>
|
| 529 |
+
<h4>Restart Bot</h4>
|
| 530 |
+
<p>Gracefully restart the bot process on Hugging Face.</p>
|
| 531 |
+
</div>
|
| 532 |
</div>
|
| 533 |
</div>
|
| 534 |
</div>
|
|
|
|
| 598 |
</div>
|
| 599 |
</div>
|
| 600 |
|
| 601 |
+
<!-- ===== LOGS PAGE ===== -->
|
| 602 |
+
<div class="page" id="page-logs">
|
| 603 |
+
<div class="topbar"><h2>Live Logs</h2></div>
|
| 604 |
+
<div class="panel">
|
| 605 |
+
<div class="panel-header"><h3>📄 Recent Activity</h3></div>
|
| 606 |
+
<div class="log-area" id="log-area">
|
| 607 |
+
<div class="log-line">[*] Waiting for log data...</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
</div>
|
| 609 |
</div>
|
| 610 |
</div>
|
|
|
|
| 677 |
<p style="font-size:12px; color:var(--text-dim); margin-top:16px">Control where global announcements from the bot owner are posted. You can opt-out by disabling this feature.</p>
|
| 678 |
</div>
|
| 679 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
<div style="border-top:1px solid var(--border); padding-top:24px; text-align:right">
|
| 681 |
<button class="invite-btn" onclick="saveConfig()" style="background:var(--accent); color:white; padding:12px 32px">Save All Changes</button>
|
| 682 |
</div>
|
|
|
|
| 732 |
loadServers();
|
| 733 |
loadCommands();
|
| 734 |
loadLogs();
|
| 735 |
+
setInterval(loadStats, 10000);
|
| 736 |
+
setInterval(loadServers, 10000);
|
| 737 |
+
setInterval(loadLogs, 8000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
}
|
| 739 |
|
| 740 |
function logout() {
|
|
|
|
| 751 |
|
| 752 |
// ===== DATA LOADERS =====
|
| 753 |
function loadStats() {
|
| 754 |
+
fetch('/api/stats')
|
| 755 |
.then(r => r.json())
|
| 756 |
.then(data => {
|
| 757 |
document.getElementById('stat-servers').textContent = data.servers || 0;
|
|
|
|
| 764 |
}
|
| 765 |
|
| 766 |
function loadServers() {
|
| 767 |
+
fetch('/api/servers')
|
| 768 |
.then(r => r.json())
|
| 769 |
.then(data => {
|
| 770 |
const servers = Array.isArray(data) ? data : (Array.isArray(data.servers) ? data.servers : []);
|
|
|
|
| 819 |
.then(r => r.json())
|
| 820 |
.then(data => {
|
| 821 |
document.getElementById('config-prefix').value = data.prefix || '!';
|
| 822 |
+
document.getElementById('config-auto-enabled').checked = data.autoFriendlyEnabled || false;
|
| 823 |
document.getElementById('config-auto-interval').value = data.autoFriendlyInterval || 40;
|
| 824 |
document.getElementById('config-post-enabled').checked = data.postEnabled !== false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
|
| 826 |
// Load channels and set selected
|
| 827 |
fetch('/api/channels/' + id)
|
|
|
|
| 847 |
postSelect.appendChild(optP);
|
| 848 |
});
|
| 849 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
});
|
| 851 |
}
|
| 852 |
|
|
|
|
| 858 |
const autoFriendlyChannel = document.getElementById('config-auto-channel').value;
|
| 859 |
const postEnabled = document.getElementById('config-post-enabled').checked;
|
| 860 |
const postChannelId = document.getElementById('config-post-channel').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
|
| 862 |
fetch('/api/config/' + activeGuildId, {
|
| 863 |
method: 'POST',
|
|
|
|
| 868 |
autoFriendlyInterval,
|
| 869 |
autoFriendlyChannel,
|
| 870 |
postEnabled,
|
| 871 |
+
postChannelId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 872 |
})
|
| 873 |
})
|
| 874 |
.then(r => r.json())
|
|
|
|
| 882 |
}
|
| 883 |
|
| 884 |
function loadCommands() {
|
| 885 |
+
fetch('/api/commands')
|
| 886 |
.then(r => r.json())
|
| 887 |
.then(data => {
|
| 888 |
const container = document.getElementById('command-list');
|
|
|
|
| 904 |
}
|
| 905 |
|
| 906 |
function loadLogs() {
|
| 907 |
+
fetch('/api/logs')
|
| 908 |
.then(r => r.json())
|
| 909 |
.then(data => {
|
| 910 |
const area = document.getElementById('log-area');
|
|
|
|
| 932 |
d.textContent = str;
|
| 933 |
return d.innerHTML;
|
| 934 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 935 |
</script>
|
| 936 |
</body>
|
| 937 |
</html>
|
db.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
| 1 |
-
"use strict";
|
| 2 |
-
const Database = require("better-sqlite3");
|
| 3 |
-
const path = require("path");
|
| 4 |
-
|
| 5 |
-
const dbPath = path.resolve(__dirname, "bot_data.db");
|
| 6 |
-
const db = new Database(dbPath);
|
| 7 |
-
|
| 8 |
-
// Initialize tables
|
| 9 |
-
db.exec(`
|
| 10 |
-
CREATE TABLE IF NOT EXISTS rosters (
|
| 11 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 12 |
-
team TEXT NOT NULL,
|
| 13 |
-
user_tag TEXT NOT NULL,
|
| 14 |
-
role TEXT NOT NULL,
|
| 15 |
-
added_at TEXT NOT NULL DEFAULT (datetime('now'))
|
| 16 |
-
);
|
| 17 |
-
CREATE INDEX IF NOT EXISTS idx_rosters_team ON rosters(team);
|
| 18 |
-
|
| 19 |
-
CREATE TABLE IF NOT EXISTS command_usage (
|
| 20 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 21 |
-
guild_id TEXT NOT NULL,
|
| 22 |
-
user_id TEXT NOT NULL,
|
| 23 |
-
user_tag TEXT NOT NULL,
|
| 24 |
-
command TEXT NOT NULL,
|
| 25 |
-
used_at TEXT NOT NULL DEFAULT (datetime('now'))
|
| 26 |
-
);
|
| 27 |
-
CREATE INDEX IF NOT EXISTS idx_command_usage_guild ON command_usage(guild_id);
|
| 28 |
-
CREATE INDEX IF NOT EXISTS idx_command_usage_user ON command_usage(user_id);
|
| 29 |
-
CREATE INDEX IF NOT EXISTS idx_command_usage_command ON command_usage(command);
|
| 30 |
-
|
| 31 |
-
CREATE TABLE IF NOT EXISTS server_stats (
|
| 32 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 33 |
-
guild_id TEXT NOT NULL UNIQUE,
|
| 34 |
-
guild_name TEXT NOT NULL,
|
| 35 |
-
member_count INTEGER DEFAULT 0,
|
| 36 |
-
commands_used INTEGER DEFAULT 0,
|
| 37 |
-
last_activity TEXT NOT NULL DEFAULT (datetime('now'))
|
| 38 |
-
);
|
| 39 |
-
CREATE INDEX IF NOT EXISTS idx_server_stats_guild ON server_stats(guild_id);
|
| 40 |
-
`);
|
| 41 |
-
|
| 42 |
-
module.exports = {
|
| 43 |
-
addRoster(team, userTag, role) {
|
| 44 |
-
const stmt = db.prepare("INSERT INTO rosters (team, user_tag, role) VALUES (?, ?, ?)");
|
| 45 |
-
stmt.run(team, userTag, role);
|
| 46 |
-
},
|
| 47 |
-
|
| 48 |
-
getRosters() {
|
| 49 |
-
const rows = db.prepare("SELECT * FROM rosters ORDER BY team, role").all();
|
| 50 |
-
const teams = {};
|
| 51 |
-
rows.forEach(row => {
|
| 52 |
-
if (!teams[row.team]) teams[row.team] = [];
|
| 53 |
-
teams[row.team].push({
|
| 54 |
-
user: row.user_tag,
|
| 55 |
-
role: row.role,
|
| 56 |
-
addedAt: row.added_at
|
| 57 |
-
});
|
| 58 |
-
});
|
| 59 |
-
return teams;
|
| 60 |
-
},
|
| 61 |
-
|
| 62 |
-
getAllRaw() {
|
| 63 |
-
return db.prepare("SELECT * FROM rosters").all();
|
| 64 |
-
},
|
| 65 |
-
|
| 66 |
-
trackCommandUsage(guildId, userId, userTag, command) {
|
| 67 |
-
const stmt = db.prepare("INSERT INTO command_usage (guild_id, user_id, user_tag, command) VALUES (?, ?, ?, ?)");
|
| 68 |
-
stmt.run(guildId, userId, userTag, command);
|
| 69 |
-
},
|
| 70 |
-
|
| 71 |
-
trackServerActivity(guildId, guildName, memberCount) {
|
| 72 |
-
const stmt = db.prepare(`
|
| 73 |
-
INSERT INTO server_stats (guild_id, guild_name, member_count, last_activity)
|
| 74 |
-
VALUES (?, ?, ?, datetime('now'))
|
| 75 |
-
ON CONFLICT(guild_id) DO UPDATE SET
|
| 76 |
-
guild_name = excluded.guild_name,
|
| 77 |
-
member_count = excluded.member_count,
|
| 78 |
-
last_activity = datetime('now'),
|
| 79 |
-
commands_used = commands_used + 1
|
| 80 |
-
`);
|
| 81 |
-
stmt.run(guildId, guildName, memberCount);
|
| 82 |
-
},
|
| 83 |
-
|
| 84 |
-
getTopCommandUsers(guildId, limit = 5) {
|
| 85 |
-
const stmt = db.prepare(`
|
| 86 |
-
SELECT user_tag, COUNT(*) as count
|
| 87 |
-
FROM command_usage
|
| 88 |
-
WHERE guild_id = ?
|
| 89 |
-
GROUP BY user_tag
|
| 90 |
-
ORDER BY count DESC
|
| 91 |
-
LIMIT ?
|
| 92 |
-
`);
|
| 93 |
-
return stmt.all(guildId, limit);
|
| 94 |
-
},
|
| 95 |
-
|
| 96 |
-
getServerStats() {
|
| 97 |
-
const stmt = db.prepare(`
|
| 98 |
-
SELECT guild_id, guild_name, member_count, commands_used, last_activity
|
| 99 |
-
FROM server_stats
|
| 100 |
-
ORDER BY commands_used DESC
|
| 101 |
-
`);
|
| 102 |
-
return stmt.all();
|
| 103 |
-
},
|
| 104 |
-
|
| 105 |
-
getGlobalStats() {
|
| 106 |
-
const stats = db.prepare(`
|
| 107 |
-
SELECT
|
| 108 |
-
COUNT(DISTINCT guild_id) as total_servers,
|
| 109 |
-
COUNT(*) as total_commands,
|
| 110 |
-
COUNT(DISTINCT user_id) as total_users
|
| 111 |
-
FROM command_usage
|
| 112 |
-
`).get();
|
| 113 |
-
return stats;
|
| 114 |
-
}
|
| 115 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
discloud.config
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ID=my-cool-bot
|
| 2 |
+
TYPE=bot
|
| 3 |
+
MAIN=server.py
|
| 4 |
+
NAME=MessageMonitor
|
| 5 |
+
RAM=512
|
| 6 |
+
VERSION=latest
|
| 7 |
+
AUTORESTART=true
|
discord-logo.svg
DELETED
dmall.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
| 1 |
-
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, MessageFlags } = require('discord.js');
|
| 2 |
-
const { UI } = require('./NewBotStyle');
|
| 3 |
-
const storage = require('./storage');
|
| 4 |
-
|
| 5 |
-
/**
|
| 6 |
-
* dmall.js
|
| 7 |
-
* Handles the !dmall command: messaging every server member and tracking responses.
|
| 8 |
-
*/
|
| 9 |
-
|
| 10 |
-
async function initiateDMAll(ctx) {
|
| 11 |
-
const isInteraction = ctx.isChatInputCommand && ctx.isChatInputCommand();
|
| 12 |
-
const author = isInteraction ? ctx.user : ctx.author;
|
| 13 |
-
const member = ctx.member;
|
| 14 |
-
const guild = ctx.guild;
|
| 15 |
-
const channel = ctx.channel;
|
| 16 |
-
|
| 17 |
-
// 1. Permission check (Admin only)
|
| 18 |
-
if (!member.permissions.has('Administrator')) {
|
| 19 |
-
const msg = "❌ **Access Denied**: Only Administrators can use `!dmall`.";
|
| 20 |
-
if (isInteraction) return ctx.reply({ content: msg, flags: [MessageFlags.Ephemeral] });
|
| 21 |
-
return ctx.reply(msg);
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
// 2. Fetch all members
|
| 25 |
-
const waitMsg = await ctx.reply({
|
| 26 |
-
content: "🔄 **Fetching members and sending DMs...** This may take a moment.",
|
| 27 |
-
fetchReply: true,
|
| 28 |
-
flags: isInteraction ? [MessageFlags.Ephemeral] : []
|
| 29 |
-
});
|
| 30 |
-
|
| 31 |
-
try {
|
| 32 |
-
await guild.members.fetch();
|
| 33 |
-
} catch (err) {
|
| 34 |
-
console.error("[DMALL] Member fetch failed:", err);
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
const members = guild.members.cache.filter(m => !m.user.bot);
|
| 38 |
-
|
| 39 |
-
const sessionId = Date.now().toString();
|
| 40 |
-
const session = {
|
| 41 |
-
guildId: guild.id,
|
| 42 |
-
channelId: channel.id,
|
| 43 |
-
messageId: null,
|
| 44 |
-
available: [], // Use array for storage compatibility
|
| 45 |
-
unavailable: [],
|
| 46 |
-
total: members.size
|
| 47 |
-
};
|
| 48 |
-
|
| 49 |
-
// 3. Create the list message in the channel
|
| 50 |
-
const statusEmbed = createStatusEmbed(session);
|
| 51 |
-
const statusMsg = await channel.send({ embeds: [statusEmbed] });
|
| 52 |
-
session.messageId = statusMsg.id;
|
| 53 |
-
|
| 54 |
-
// Save session to persistent storage
|
| 55 |
-
storage.data.dmall_sessions[sessionId] = session;
|
| 56 |
-
storage.save('active_polls'); // Using active_polls type as it triggers saveState
|
| 57 |
-
|
| 58 |
-
// 4. Send DMs
|
| 59 |
-
const dmEmbed = new EmbedBuilder()
|
| 60 |
-
.setTitle(`🎮 Server Invitation: ${guild.name}`)
|
| 61 |
-
.setDescription(`Hello! You've been invited to participate in a match or event in **${guild.name}**.\n\nPlease let us know if you are available to play by clicking a button below!`)
|
| 62 |
-
.setColor(UI.colors.primary)
|
| 63 |
-
.setThumbnail(guild.iconURL({ dynamic: true }))
|
| 64 |
-
.setFooter({ text: "FriendlyBot Pro • DM Invitation" })
|
| 65 |
-
.setTimestamp();
|
| 66 |
-
|
| 67 |
-
const row = new ActionRowBuilder().addComponents(
|
| 68 |
-
new ButtonBuilder()
|
| 69 |
-
.setCustomId(`dmall_accept_${sessionId}`)
|
| 70 |
-
.setLabel('Accept')
|
| 71 |
-
.setStyle(ButtonStyle.Success)
|
| 72 |
-
.setEmoji('✅'),
|
| 73 |
-
new ButtonBuilder()
|
| 74 |
-
.setCustomId(`dmall_decline_${sessionId}`)
|
| 75 |
-
.setLabel('Decline')
|
| 76 |
-
.setStyle(ButtonStyle.Danger)
|
| 77 |
-
.setEmoji('❌')
|
| 78 |
-
);
|
| 79 |
-
|
| 80 |
-
let sentCount = 0;
|
| 81 |
-
let processedCount = 0;
|
| 82 |
-
for (const [id, member] of members) {
|
| 83 |
-
// Skip muted users
|
| 84 |
-
if (storage.data.muted_users && storage.data.muted_users[member.id]) {
|
| 85 |
-
processedCount++;
|
| 86 |
-
continue;
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
try {
|
| 90 |
-
await member.send({ embeds: [dmEmbed], components: [row] });
|
| 91 |
-
sentCount++;
|
| 92 |
-
} catch (err) {
|
| 93 |
-
// Ignore members with closed DMs
|
| 94 |
-
}
|
| 95 |
-
|
| 96 |
-
processedCount++;
|
| 97 |
-
// Delay 4 seconds per person to avoid rate limiting
|
| 98 |
-
await new Promise(resolve => setTimeout(resolve, 4000));
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
const successMsg = `✅ **DM-All Complete**: Successfully sent invitations to **${sentCount}** members.`;
|
| 102 |
-
if (isInteraction) {
|
| 103 |
-
await ctx.editReply(successMsg);
|
| 104 |
-
} else {
|
| 105 |
-
await waitMsg.edit(successMsg);
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function createStatusEmbed(session) {
|
| 110 |
-
const availableList = session.available && session.available.length > 0
|
| 111 |
-
? session.available.map(id => `<@${id}>`).join('\n')
|
| 112 |
-
: "*No one yet*";
|
| 113 |
-
|
| 114 |
-
const unavailableList = session.unavailable && session.unavailable.length > 0
|
| 115 |
-
? session.unavailable.map(id => `<@${id}>`).join('\n')
|
| 116 |
-
: "*No one yet*";
|
| 117 |
-
|
| 118 |
-
const respondedCount = (session.available?.length || 0) + (session.unavailable?.length || 0);
|
| 119 |
-
|
| 120 |
-
return new EmbedBuilder()
|
| 121 |
-
.setTitle("📊 Player Availability List")
|
| 122 |
-
.setDescription(`Tracking responses for the latest **!dmall** invitation.`)
|
| 123 |
-
.addFields(
|
| 124 |
-
{ name: `✅ Available (${session.available?.length || 0})`, value: availableList, inline: true },
|
| 125 |
-
{ name: `❌ Unavailable (${session.unavailable?.length || 0})`, value: unavailableList, inline: true }
|
| 126 |
-
)
|
| 127 |
-
.setColor(UI.colors.primary)
|
| 128 |
-
.setFooter({ text: `Progress: ${respondedCount}/${session.total} members responded` })
|
| 129 |
-
.setTimestamp();
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
async function handleResponse(interaction) {
|
| 133 |
-
if (!interaction.isButton() || !interaction.customId.startsWith('dmall_')) return;
|
| 134 |
-
|
| 135 |
-
const parts = interaction.customId.split('_');
|
| 136 |
-
const action = parts[1]; // accept or decline
|
| 137 |
-
const sessionId = parts[2];
|
| 138 |
-
|
| 139 |
-
const session = storage.data.dmall_sessions[sessionId];
|
| 140 |
-
if (!session) {
|
| 141 |
-
return interaction.reply({ content: "❌ This session has expired or the bot has restarted.", flags: [MessageFlags.Ephemeral] });
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
const userId = interaction.user.id;
|
| 145 |
-
|
| 146 |
-
// Ensure arrays exist
|
| 147 |
-
if (!session.available) session.available = [];
|
| 148 |
-
if (!session.unavailable) session.unavailable = [];
|
| 149 |
-
|
| 150 |
-
// Remove from both lists first to handle changing response
|
| 151 |
-
session.available = session.available.filter(id => id !== userId);
|
| 152 |
-
session.unavailable = session.unavailable.filter(id => id !== userId);
|
| 153 |
-
|
| 154 |
-
if (action === 'accept') {
|
| 155 |
-
session.available.push(userId);
|
| 156 |
-
} else {
|
| 157 |
-
session.unavailable.push(userId);
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
// Save changes
|
| 161 |
-
storage.save('active_polls');
|
| 162 |
-
|
| 163 |
-
// Update the DM message
|
| 164 |
-
await interaction.update({
|
| 165 |
-
content: `✅ **Response Recorded**: You are marked as **${action === 'accept' ? 'Available' : 'Unavailable'}**. Thank you!`,
|
| 166 |
-
components: [],
|
| 167 |
-
embeds: []
|
| 168 |
-
});
|
| 169 |
-
|
| 170 |
-
// Update the channel message
|
| 171 |
-
try {
|
| 172 |
-
const client = interaction.client;
|
| 173 |
-
const channel = await client.channels.fetch(session.channelId);
|
| 174 |
-
if (channel) {
|
| 175 |
-
const msg = await channel.messages.fetch(session.messageId);
|
| 176 |
-
if (msg) {
|
| 177 |
-
await msg.edit({ embeds: [createStatusEmbed(session)] });
|
| 178 |
-
}
|
| 179 |
-
}
|
| 180 |
-
} catch (err) {
|
| 181 |
-
console.error("[DMALL] Failed to update status message:", err.message);
|
| 182 |
-
}
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
module.exports = {
|
| 186 |
-
initiateDMAll,
|
| 187 |
-
handleResponse
|
| 188 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emergency_handler.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* emergency_handler.js
|
| 3 |
-
* A lightweight, high-priority command listener to ensure the bot responds.
|
| 4 |
-
*/
|
| 5 |
-
console.log(">>> [DEBUG] Emergency Handler loading...");
|
| 6 |
-
|
| 7 |
-
module.exports = function(client) {
|
| 8 |
-
client.on('messageCreate', async (message) => {
|
| 9 |
-
// Ignore bots
|
| 10 |
-
if (message.author.bot) return;
|
| 11 |
-
|
| 12 |
-
const content = message.content.toLowerCase();
|
| 13 |
-
|
| 14 |
-
// 1. Simple word-match test (No prefix needed)
|
| 15 |
-
if (content === 'ping') {
|
| 16 |
-
console.log(`[DEBUG] Received 'ping' from ${message.author.tag}`);
|
| 17 |
-
return message.reply('pong! I am alive and listening. 🚀');
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
// 2. Simple prefix test (!test)
|
| 21 |
-
if (content === '!test') {
|
| 22 |
-
console.log(`[DEBUG] Received '!test' from ${message.author.tag}`);
|
| 23 |
-
return message.reply('✅ Success! The emergency prefix handler is working.');
|
| 24 |
-
}
|
| 25 |
-
});
|
| 26 |
-
|
| 27 |
-
client.on('interactionCreate', async (interaction) => {
|
| 28 |
-
if (!interaction.isChatInputCommand()) return;
|
| 29 |
-
|
| 30 |
-
if (interaction.commandName === 'ping') {
|
| 31 |
-
console.log(`[DEBUG] Received Slash Command /ping from ${interaction.user.tag}`);
|
| 32 |
-
await interaction.reply('🚀 Slash commands are working! Latency: ' + client.ws.ping + 'ms');
|
| 33 |
-
}
|
| 34 |
-
});
|
| 35 |
-
|
| 36 |
-
console.log(">>> [DEBUG] Emergency Handler active. Try typing 'ping' in Discord.");
|
| 37 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grant_system.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
const storage = require('./storage');
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* grant_system.js
|
| 5 |
-
* Manages administrative access to sensitive global commands like !servers
|
| 6 |
-
*/
|
| 7 |
-
|
| 8 |
-
// Initialize storage if needed
|
| 9 |
-
if (!storage.data.settings) storage.data.settings = {};
|
| 10 |
-
if (!storage.data.settings.serverViewers) storage.data.settings.serverViewers = [];
|
| 11 |
-
|
| 12 |
-
async function grantAccess(client, userId, grantorId) {
|
| 13 |
-
const app = await client.application.fetch();
|
| 14 |
-
const ownerId = app.owner?.ownerId || app.owner?.id;
|
| 15 |
-
|
| 16 |
-
// Only owner can grant
|
| 17 |
-
if (grantorId !== ownerId) return { success: false, message: "Only the Bot Owner can grant access." };
|
| 18 |
-
|
| 19 |
-
if (!storage.data.settings.serverViewers.includes(userId)) {
|
| 20 |
-
storage.data.settings.serverViewers.push(userId);
|
| 21 |
-
storage.save('settings');
|
| 22 |
-
return { success: true, message: `Access granted to <@${userId}>.` };
|
| 23 |
-
}
|
| 24 |
-
return { success: false, message: "User already has access." };
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
async function revokeAccess(client, userId, grantorId) {
|
| 28 |
-
const app = await client.application.fetch();
|
| 29 |
-
const ownerId = app.owner?.ownerId || app.owner?.id;
|
| 30 |
-
|
| 31 |
-
if (grantorId !== ownerId) return { success: false, message: "Only the Bot Owner can revoke access." };
|
| 32 |
-
|
| 33 |
-
const index = storage.data.settings.serverViewers.indexOf(userId);
|
| 34 |
-
if (index > -1) {
|
| 35 |
-
storage.data.settings.serverViewers.splice(index, 1);
|
| 36 |
-
storage.save('settings');
|
| 37 |
-
return { success: true, message: `Access revoked for <@${userId}>.` };
|
| 38 |
-
}
|
| 39 |
-
return { success: false, message: "User does not have access." };
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
function hasAccess(userId, ownerId) {
|
| 43 |
-
if (userId === ownerId) return true;
|
| 44 |
-
return storage.data.settings.serverViewers.includes(userId);
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
module.exports = {
|
| 48 |
-
grantAccess,
|
| 49 |
-
revokeAccess,
|
| 50 |
-
hasAccess
|
| 51 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hyper_fix.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
const dns = require('dns');
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* HYPER-FIX FOR HUGGING FACE
|
| 5 |
-
* Minimal version — only sets IPv4-first DNS (which ultimate_fix.js also does).
|
| 6 |
-
* All connection agent/dispatcher logic is consolidated in ultimate_fix.js.
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
console.log("[HYPER-FIX] Initializing...");
|
| 10 |
-
|
| 11 |
-
// Force IPv4 (redundant with ultimate_fix.js but harmless as a safety net)
|
| 12 |
-
dns.setDefaultResultOrder('ipv4first');
|
| 13 |
-
|
| 14 |
-
console.log("[HYPER-FIX] IPv4-first DNS set. Done.");
|
| 15 |
-
|
| 16 |
-
module.exports = { enabled: true };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
league.html
DELETED
|
@@ -1,636 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>FriendlyBot League — Official Website</title>
|
| 7 |
-
<link rel="icon" href="/logo.png">
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #050510;
|
| 12 |
-
--surface: #0f0f25;
|
| 13 |
-
--surface-light: #1a1a3a;
|
| 14 |
-
--accent: #5865F2;
|
| 15 |
-
--accent-gradient: linear-gradient(135deg, #5865F2 0%, #3b82f6 100%);
|
| 16 |
-
--gold: #FFD700;
|
| 17 |
-
--gold-gradient: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
|
| 18 |
-
--text: #ffffff;
|
| 19 |
-
--text-dim: rgba(255, 255, 255, 0.6);
|
| 20 |
-
--border: rgba(255, 255, 255, 0.08);
|
| 21 |
-
--radius: 20px;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
* {
|
| 25 |
-
margin: 0;
|
| 26 |
-
padding: 0;
|
| 27 |
-
box-sizing: border-box;
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
body {
|
| 31 |
-
font-family: 'Outfit', sans-serif;
|
| 32 |
-
background: var(--bg);
|
| 33 |
-
color: var(--text);
|
| 34 |
-
line-height: 1.6;
|
| 35 |
-
overflow-x: hidden;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
/* Background Glows */
|
| 39 |
-
.glow {
|
| 40 |
-
position: fixed;
|
| 41 |
-
width: 600px;
|
| 42 |
-
height: 600px;
|
| 43 |
-
background: radial-gradient(circle, rgba(88, 101, 242, 0.1) 0%, transparent 70%);
|
| 44 |
-
border-radius: 50%;
|
| 45 |
-
z-index: -1;
|
| 46 |
-
pointer-events: none;
|
| 47 |
-
}
|
| 48 |
-
.glow-1 { top: -200px; right: -200px; }
|
| 49 |
-
.glow-2 { bottom: -200px; left: -200px; }
|
| 50 |
-
|
| 51 |
-
header {
|
| 52 |
-
padding: 30px 5%;
|
| 53 |
-
display: flex;
|
| 54 |
-
justify-content: space-between;
|
| 55 |
-
align-items: center;
|
| 56 |
-
background: rgba(5, 5, 16, 0.8);
|
| 57 |
-
backdrop-filter: blur(10px);
|
| 58 |
-
position: sticky;
|
| 59 |
-
top: 0;
|
| 60 |
-
z-index: 100;
|
| 61 |
-
border-bottom: 1px solid var(--border);
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
.brand {
|
| 65 |
-
display: flex;
|
| 66 |
-
align-items: center;
|
| 67 |
-
gap: 15px;
|
| 68 |
-
font-size: 24px;
|
| 69 |
-
font-weight: 800;
|
| 70 |
-
letter-spacing: -0.5px;
|
| 71 |
-
text-decoration: none;
|
| 72 |
-
color: white;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
.brand img {
|
| 76 |
-
width: 45px;
|
| 77 |
-
height: 45px;
|
| 78 |
-
border-radius: 50%;
|
| 79 |
-
box-shadow: 0 0 20px rgba(88, 101, 242, 0.4);
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
.nav-links {
|
| 83 |
-
display: flex;
|
| 84 |
-
gap: 20px;
|
| 85 |
-
align-items: center;
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
.btn-dashboard {
|
| 89 |
-
padding: 10px 24px;
|
| 90 |
-
border-radius: 12px;
|
| 91 |
-
background: var(--surface-light);
|
| 92 |
-
color: white;
|
| 93 |
-
text-decoration: none;
|
| 94 |
-
font-weight: 600;
|
| 95 |
-
font-size: 14px;
|
| 96 |
-
border: 1px solid var(--border);
|
| 97 |
-
transition: all 0.3s ease;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
.btn-dashboard:hover {
|
| 101 |
-
background: var(--accent);
|
| 102 |
-
transform: translateY(-2px);
|
| 103 |
-
box-shadow: 0 10px 20px rgba(88, 101, 242, 0.3);
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
.hero {
|
| 107 |
-
padding: 100px 5% 60px;
|
| 108 |
-
text-align: center;
|
| 109 |
-
max-width: 1000px;
|
| 110 |
-
margin: 0 auto;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
.hero h1 {
|
| 114 |
-
font-size: 64px;
|
| 115 |
-
font-weight: 800;
|
| 116 |
-
margin-bottom: 20px;
|
| 117 |
-
background: linear-gradient(to right, #fff, var(--text-dim));
|
| 118 |
-
-webkit-background-clip: text;
|
| 119 |
-
-webkit-text-fill-color: transparent;
|
| 120 |
-
line-height: 1.1;
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
.hero p {
|
| 124 |
-
font-size: 18px;
|
| 125 |
-
color: var(--text-dim);
|
| 126 |
-
max-width: 700px;
|
| 127 |
-
margin: 0 auto 40px;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
.cta-box {
|
| 131 |
-
background: var(--gold-gradient);
|
| 132 |
-
padding: 30px;
|
| 133 |
-
border-radius: var(--radius);
|
| 134 |
-
display: inline-flex;
|
| 135 |
-
flex-direction: column;
|
| 136 |
-
align-items: center;
|
| 137 |
-
gap: 15px;
|
| 138 |
-
color: #000;
|
| 139 |
-
box-shadow: 0 20px 40px rgba(255, 215, 0, 0.2);
|
| 140 |
-
animation: float 6s ease-in-out infinite;
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
@keyframes float {
|
| 144 |
-
0%, 100% { transform: translateY(0); }
|
| 145 |
-
50% { transform: translateY(-10px); }
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
.cta-box h2 {
|
| 149 |
-
font-size: 20px;
|
| 150 |
-
font-weight: 800;
|
| 151 |
-
}
|
| 152 |
-
|
| 153 |
-
.btn-join {
|
| 154 |
-
background: #000;
|
| 155 |
-
color: #fff;
|
| 156 |
-
padding: 12px 30px;
|
| 157 |
-
border-radius: 12px;
|
| 158 |
-
text-decoration: none;
|
| 159 |
-
font-weight: 700;
|
| 160 |
-
transition: all 0.3s;
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
.btn-join:hover {
|
| 164 |
-
transform: scale(1.05);
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
.container {
|
| 168 |
-
padding: 60px 5%;
|
| 169 |
-
max-width: 1400px;
|
| 170 |
-
margin: 0 auto;
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
.section-title {
|
| 174 |
-
font-size: 32px;
|
| 175 |
-
font-weight: 800;
|
| 176 |
-
margin-bottom: 40px;
|
| 177 |
-
display: flex;
|
| 178 |
-
align-items: center;
|
| 179 |
-
gap: 15px;
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
.section-title::after {
|
| 183 |
-
content: '';
|
| 184 |
-
flex: 1;
|
| 185 |
-
height: 1px;
|
| 186 |
-
background: var(--border);
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
.teams-grid {
|
| 190 |
-
display: grid;
|
| 191 |
-
grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
|
| 192 |
-
gap: 25px;
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
.team-card {
|
| 196 |
-
background: var(--surface);
|
| 197 |
-
border: 1px solid var(--border);
|
| 198 |
-
border-radius: var(--radius);
|
| 199 |
-
padding: 25px;
|
| 200 |
-
position: relative;
|
| 201 |
-
overflow: hidden;
|
| 202 |
-
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
| 203 |
-
cursor: pointer;
|
| 204 |
-
height: fit-content;
|
| 205 |
-
}
|
| 206 |
-
|
| 207 |
-
.team-card:hover {
|
| 208 |
-
border-color: var(--accent);
|
| 209 |
-
transform: translateY(-5px);
|
| 210 |
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
|
| 211 |
-
}
|
| 212 |
-
|
| 213 |
-
.team-card.expanded {
|
| 214 |
-
border-color: var(--accent);
|
| 215 |
-
box-shadow: 0 0 30px rgba(88, 101, 242, 0.2);
|
| 216 |
-
}
|
| 217 |
-
|
| 218 |
-
.team-card::before {
|
| 219 |
-
content: '';
|
| 220 |
-
position: absolute;
|
| 221 |
-
top: 0;
|
| 222 |
-
left: 0;
|
| 223 |
-
width: 100%;
|
| 224 |
-
height: 6px;
|
| 225 |
-
background: var(--accent);
|
| 226 |
-
}
|
| 227 |
-
|
| 228 |
-
.team-header {
|
| 229 |
-
display: flex;
|
| 230 |
-
align-items: center;
|
| 231 |
-
justify-content: space-between;
|
| 232 |
-
gap: 15px;
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
.team-header-main {
|
| 236 |
-
display: flex;
|
| 237 |
-
align-items: center;
|
| 238 |
-
gap: 15px;
|
| 239 |
-
}
|
| 240 |
-
|
| 241 |
-
.team-icon {
|
| 242 |
-
width: 50px;
|
| 243 |
-
height: 50px;
|
| 244 |
-
background: var(--surface-light);
|
| 245 |
-
border-radius: 12px;
|
| 246 |
-
display: flex;
|
| 247 |
-
align-items: center;
|
| 248 |
-
justify-content: center;
|
| 249 |
-
font-size: 24px;
|
| 250 |
-
font-weight: 800;
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
.team-info h3 {
|
| 254 |
-
font-size: 22px;
|
| 255 |
-
font-weight: 700;
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
.expand-hint {
|
| 259 |
-
font-size: 12px;
|
| 260 |
-
color: var(--accent);
|
| 261 |
-
font-weight: 700;
|
| 262 |
-
text-transform: uppercase;
|
| 263 |
-
letter-spacing: 1px;
|
| 264 |
-
display: flex;
|
| 265 |
-
align-items: center;
|
| 266 |
-
gap: 5px;
|
| 267 |
-
transition: all 0.3s;
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
.team-card.expanded .expand-hint {
|
| 271 |
-
transform: rotate(180deg);
|
| 272 |
-
color: var(--text-dim);
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
.manager-simple {
|
| 276 |
-
margin-top: 10px;
|
| 277 |
-
font-size: 14px;
|
| 278 |
-
color: var(--text-dim);
|
| 279 |
-
font-weight: 500;
|
| 280 |
-
}
|
| 281 |
-
|
| 282 |
-
.team-details {
|
| 283 |
-
max-height: 0;
|
| 284 |
-
overflow: hidden;
|
| 285 |
-
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
| 286 |
-
opacity: 0;
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
.team-card.expanded .team-details {
|
| 290 |
-
max-height: 500px;
|
| 291 |
-
opacity: 1;
|
| 292 |
-
margin-top: 25px;
|
| 293 |
-
}
|
| 294 |
-
|
| 295 |
-
.team-meta {
|
| 296 |
-
display: grid;
|
| 297 |
-
grid-template-columns: 1fr 1fr;
|
| 298 |
-
gap: 15px;
|
| 299 |
-
margin-bottom: 25px;
|
| 300 |
-
padding: 15px;
|
| 301 |
-
background: rgba(255, 255, 255, 0.03);
|
| 302 |
-
border-radius: 12px;
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
.meta-item label {
|
| 306 |
-
display: block;
|
| 307 |
-
font-size: 11px;
|
| 308 |
-
text-transform: uppercase;
|
| 309 |
-
color: var(--text-dim);
|
| 310 |
-
font-weight: 700;
|
| 311 |
-
letter-spacing: 1px;
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
.meta-item span {
|
| 315 |
-
font-size: 14px;
|
| 316 |
-
font-weight: 600;
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
.roster-title {
|
| 320 |
-
font-size: 13px;
|
| 321 |
-
font-weight: 700;
|
| 322 |
-
color: var(--text-dim);
|
| 323 |
-
margin-bottom: 12px;
|
| 324 |
-
text-transform: uppercase;
|
| 325 |
-
display: flex;
|
| 326 |
-
align-items: center;
|
| 327 |
-
gap: 8px;
|
| 328 |
-
}
|
| 329 |
-
|
| 330 |
-
.roster-list {
|
| 331 |
-
list-style: none;
|
| 332 |
-
display: flex;
|
| 333 |
-
flex-wrap: wrap;
|
| 334 |
-
gap: 8px;
|
| 335 |
-
}
|
| 336 |
-
|
| 337 |
-
.player-tag {
|
| 338 |
-
background: var(--surface-light);
|
| 339 |
-
padding: 6px 14px;
|
| 340 |
-
border-radius: 100px;
|
| 341 |
-
font-size: 13px;
|
| 342 |
-
font-weight: 500;
|
| 343 |
-
border: 1px solid var(--border);
|
| 344 |
-
}
|
| 345 |
-
|
| 346 |
-
footer {
|
| 347 |
-
padding: 60px 5%;
|
| 348 |
-
text-align: center;
|
| 349 |
-
border-top: 1px solid var(--border);
|
| 350 |
-
margin-top: 60px;
|
| 351 |
-
color: var(--text-dim);
|
| 352 |
-
font-size: 14px;
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
@media (max-width: 768px) {
|
| 356 |
-
.hero h1 { font-size: 40px; }
|
| 357 |
-
header { padding: 20px 5%; }
|
| 358 |
-
.nav-links { display: none; }
|
| 359 |
-
}
|
| 360 |
-
</style>
|
| 361 |
-
</head>
|
| 362 |
-
<body>
|
| 363 |
-
<div class="glow glow-1"></div>
|
| 364 |
-
<div class="glow glow-2"></div>
|
| 365 |
-
|
| 366 |
-
<header>
|
| 367 |
-
<a href="/" class="brand">
|
| 368 |
-
<img src="/logo.png" alt="FriendlyBot">
|
| 369 |
-
FriendlyBot League
|
| 370 |
-
</a>
|
| 371 |
-
<div class="nav-links">
|
| 372 |
-
<a href="/" class="btn-dashboard">Dashboard</a>
|
| 373 |
-
</div>
|
| 374 |
-
</header>
|
| 375 |
-
|
| 376 |
-
<section class="hero">
|
| 377 |
-
<h1>The Ultimate Arena</h1>
|
| 378 |
-
<p>Compete, win, and earn premium rewards. The FriendlyBot League is where legends are made. Join 50+ teams in the quest for glory.</p>
|
| 379 |
-
|
| 380 |
-
<div class="cta-box">
|
| 381 |
-
<h2>🏆 Winner Wins Premium Features!</h2>
|
| 382 |
-
<p style="color: #000; font-size: 14px; margin-bottom: 0;">Exclusive bot upgrades, custom themes, and advanced analytics await.</p>
|
| 383 |
-
<a href="https://discord.gg/vpHd4Xfm" target="_blank" class="btn-join" style="display: flex; align-items: center; gap: 10px; background: #5865F2; color: white;">
|
| 384 |
-
<svg width="20" height="20" viewBox="0 0 24 24" aria-label="Discord" role="img" fill="#fff" style="flex:0 0 auto;">
|
| 385 |
-
<circle cx="12" cy="12" r="10" fill="#5865F2" />
|
| 386 |
-
<text x="12" y="16" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#fff" font-weight="bold">D</text>
|
| 387 |
-
</svg>
|
| 388 |
-
Join Discord League
|
| 389 |
-
</a>
|
| 390 |
-
</div>
|
| 391 |
-
</section>
|
| 392 |
-
|
| 393 |
-
<div class="container">
|
| 394 |
-
<h2 class="section-title">Participating Teams</h2>
|
| 395 |
-
|
| 396 |
-
<div class="teams-grid">
|
| 397 |
-
<!-- Team 1 -->
|
| 398 |
-
<div class="team-card" style="border-top-color: #ED4245;">
|
| 399 |
-
<div class="team-header">
|
| 400 |
-
<div class="team-header-main">
|
| 401 |
-
<div class="team-icon" style="color: #ED4245;">FC</div>
|
| 402 |
-
<div class="team-info">
|
| 403 |
-
<h3>FC Barcelona</h3>
|
| 404 |
-
</div>
|
| 405 |
-
</div>
|
| 406 |
-
<div class="expand-hint">▼</div>
|
| 407 |
-
</div>
|
| 408 |
-
<div class="manager-simple">Manager: Luis Martínez</div>
|
| 409 |
-
|
| 410 |
-
<div class="team-details">
|
| 411 |
-
<div class="team-meta">
|
| 412 |
-
<div class="meta-item">
|
| 413 |
-
<label>Manager</label>
|
| 414 |
-
<span>Luis Martínez</span>
|
| 415 |
-
</div>
|
| 416 |
-
<div class="meta-item">
|
| 417 |
-
<label>Assistant</label>
|
| 418 |
-
<span>Marta López</span>
|
| 419 |
-
</div>
|
| 420 |
-
</div>
|
| 421 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 422 |
-
<ul class="roster-list">
|
| 423 |
-
<li class="player-tag">Marc Serrano</li>
|
| 424 |
-
<li class="player-tag">Alejandro Ruiz</li>
|
| 425 |
-
<li class="player-tag">Jonas Villar</li>
|
| 426 |
-
<li class="player-tag">Carlos Mendez</li>
|
| 427 |
-
<li class="player-tag">Diego Alvarez</li>
|
| 428 |
-
</ul>
|
| 429 |
-
</div>
|
| 430 |
-
</div>
|
| 431 |
-
|
| 432 |
-
<!-- Team 2 -->
|
| 433 |
-
<div class="team-card" style="border-top-color: #FFFFFF;">
|
| 434 |
-
<div class="team-header">
|
| 435 |
-
<div class="team-header-main">
|
| 436 |
-
<div class="team-icon" style="color: #fff; background: #333;">RM</div>
|
| 437 |
-
<div class="team-info">
|
| 438 |
-
<h3>Real Madrid CF</h3>
|
| 439 |
-
</div>
|
| 440 |
-
</div>
|
| 441 |
-
<div class="expand-hint">▼</div>
|
| 442 |
-
</div>
|
| 443 |
-
<div class="manager-simple">Manager: Elena García</div>
|
| 444 |
-
|
| 445 |
-
<div class="team-details">
|
| 446 |
-
<div class="team-meta">
|
| 447 |
-
<div class="meta-item">
|
| 448 |
-
<label>Manager</label>
|
| 449 |
-
<span>Elena García</span>
|
| 450 |
-
</div>
|
| 451 |
-
<div class="meta-item">
|
| 452 |
-
<label>Assistant</label>
|
| 453 |
-
<span>Diego Ramirez</span>
|
| 454 |
-
</div>
|
| 455 |
-
</div>
|
| 456 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 457 |
-
<ul class="roster-list">
|
| 458 |
-
<li class="player-tag">Alvaro Jiménez</li>
|
| 459 |
-
<li class="player-tag">Mateo Ruiz</li>
|
| 460 |
-
<li class="player-tag">Sergio Navarro</li>
|
| 461 |
-
<li class="player-tag">Raúl Santos</li>
|
| 462 |
-
<li class="player-tag">Luis Ortega</li>
|
| 463 |
-
</ul>
|
| 464 |
-
</div>
|
| 465 |
-
</div>
|
| 466 |
-
|
| 467 |
-
<!-- Team 3 -->
|
| 468 |
-
<div class="team-card" style="border-top-color: #E11D48;">
|
| 469 |
-
<div class="team-header">
|
| 470 |
-
<div class="team-header-main">
|
| 471 |
-
<div class="team-icon" style="color: #E11D48;">SF</div>
|
| 472 |
-
<div class="team-info">
|
| 473 |
-
<h3>Sevilla FC</h3>
|
| 474 |
-
</div>
|
| 475 |
-
</div>
|
| 476 |
-
<div class="expand-hint">▼</div>
|
| 477 |
-
</div>
|
| 478 |
-
<div class="manager-simple">Manager: Pablo Cárdenas</div>
|
| 479 |
-
|
| 480 |
-
<div class="team-details">
|
| 481 |
-
<div class="team-meta">
|
| 482 |
-
<div class="meta-item">
|
| 483 |
-
<label>Manager</label>
|
| 484 |
-
<span>Pablo Cárdenas</span>
|
| 485 |
-
</div>
|
| 486 |
-
<div class="meta-item">
|
| 487 |
-
<label>Assistant</label>
|
| 488 |
-
<span>Lucía Peña</span>
|
| 489 |
-
</div>
|
| 490 |
-
</div>
|
| 491 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 492 |
-
<ul class="roster-list">
|
| 493 |
-
<li class="player-tag">Ignacio Lara</li>
|
| 494 |
-
<li class="player-tag">Adrián Vega</li>
|
| 495 |
-
<li class="player-tag">Marcos Gil</li>
|
| 496 |
-
<li class="player-tag">Rafael Soto</li>
|
| 497 |
-
<li class="player-tag">Camilo Cruz</li>
|
| 498 |
-
</ul>
|
| 499 |
-
</div>
|
| 500 |
-
</div>
|
| 501 |
-
|
| 502 |
-
<!-- Team 4 -->
|
| 503 |
-
<div class="team-card" style="border-top-color: #1D4ED8;">
|
| 504 |
-
<div class="team-header">
|
| 505 |
-
<div class="team-header-main">
|
| 506 |
-
<div class="team-icon" style="color: #1D4ED8;">AM</div>
|
| 507 |
-
<div class="team-info">
|
| 508 |
-
<h3>Atlético Madrid</h3>
|
| 509 |
-
</div>
|
| 510 |
-
</div>
|
| 511 |
-
<div class="expand-hint">▼</div>
|
| 512 |
-
</div>
|
| 513 |
-
<div class="manager-simple">Manager: Diego Costa</div>
|
| 514 |
-
|
| 515 |
-
<div class="team-details">
|
| 516 |
-
<div class="team-meta">
|
| 517 |
-
<div class="meta-item">
|
| 518 |
-
<label>Manager</label>
|
| 519 |
-
<span>Diego Costa</span>
|
| 520 |
-
</div>
|
| 521 |
-
<div class="meta-item">
|
| 522 |
-
<label>Assistant</label>
|
| 523 |
-
<span>Isabel Ramos</span>
|
| 524 |
-
</div>
|
| 525 |
-
</div>
|
| 526 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 527 |
-
<ul class="roster-list">
|
| 528 |
-
<li class="player-tag">Daniel Herrera</li>
|
| 529 |
-
<li class="player-tag">Jorge Perez</li>
|
| 530 |
-
<li class="player-tag">Martín Ruiz</li>
|
| 531 |
-
<li class="player-tag">Alex Torres</li>
|
| 532 |
-
<li class="player-tag">Lucas Vega</li>
|
| 533 |
-
</ul>
|
| 534 |
-
</div>
|
| 535 |
-
</div>
|
| 536 |
-
|
| 537 |
-
<!-- Team 5 -->
|
| 538 |
-
<div class="team-card" style="border-top-color: #10B981;">
|
| 539 |
-
<div class="team-header">
|
| 540 |
-
<div class="team-header-main">
|
| 541 |
-
<div class="team-icon" style="color: #10B981;">RB</div>
|
| 542 |
-
<div class="team-info">
|
| 543 |
-
<h3>Real Betis</h3>
|
| 544 |
-
</div>
|
| 545 |
-
</div>
|
| 546 |
-
<div class="expand-hint">▼</div>
|
| 547 |
-
</div>
|
| 548 |
-
<div class="manager-simple">Manager: Sofia Mendez</div>
|
| 549 |
-
|
| 550 |
-
<div class="team-details">
|
| 551 |
-
<div class="team-meta">
|
| 552 |
-
<div class="meta-item">
|
| 553 |
-
<label>Manager</label>
|
| 554 |
-
<span>Sofia Mendez</span>
|
| 555 |
-
</div>
|
| 556 |
-
<div class="meta-item">
|
| 557 |
-
<label>Assistant</label>
|
| 558 |
-
<span>Omar Ruiz</span>
|
| 559 |
-
</div>
|
| 560 |
-
</div>
|
| 561 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 562 |
-
<ul class="roster-list">
|
| 563 |
-
<li class="player-tag">Alejandro Fuentes</li>
|
| 564 |
-
<li class="player-tag">Diego Morales</li>
|
| 565 |
-
<li class="player-tag">Nico Aguirre</li>
|
| 566 |
-
<li class="player-tag">Javi Cordero</li>
|
| 567 |
-
<li class="player-tag">Tomás Cruz</li>
|
| 568 |
-
</ul>
|
| 569 |
-
</div>
|
| 570 |
-
</div>
|
| 571 |
-
|
| 572 |
-
<!-- Team 6 -->
|
| 573 |
-
<div class="team-card" style="border-top-color: #F59E0B;">
|
| 574 |
-
<div class="team-header">
|
| 575 |
-
<div class="team-header-main">
|
| 576 |
-
<div class="team-icon" style="color: #F59E0B;">AC</div>
|
| 577 |
-
<div class="team-info">
|
| 578 |
-
<h3>Athletic Club</h3>
|
| 579 |
-
</div>
|
| 580 |
-
</div>
|
| 581 |
-
<div class="expand-hint">▼</div>
|
| 582 |
-
</div>
|
| 583 |
-
<div class="manager-simple">Manager: Iker Aranzazu</div>
|
| 584 |
-
|
| 585 |
-
<div class="team-details">
|
| 586 |
-
<div class="team-meta">
|
| 587 |
-
<div class="meta-item">
|
| 588 |
-
<label>Manager</label>
|
| 589 |
-
<span>Iker Aranzazu</span>
|
| 590 |
-
</div>
|
| 591 |
-
<div class="meta-item">
|
| 592 |
-
<label>Assistant</label>
|
| 593 |
-
<span>Marta Larra</span>
|
| 594 |
-
</div>
|
| 595 |
-
</div>
|
| 596 |
-
<div class="roster-title">👥 Active Roster</div>
|
| 597 |
-
<ul class="roster-list">
|
| 598 |
-
<li class="player-tag">Jon Etxeberria</li>
|
| 599 |
-
<li class="player-tag">Oier Zabaleta</li>
|
| 600 |
-
<li class="player-tag">Unai Arrieta</li>
|
| 601 |
-
<li class="player-tag">Nerea Bello</li>
|
| 602 |
-
<li class="player-tag">Ainhoa Etxe</li>
|
| 603 |
-
</ul>
|
| 604 |
-
</div>
|
| 605 |
-
</div>
|
| 606 |
-
</div>
|
| 607 |
-
</div>
|
| 608 |
-
|
| 609 |
-
<footer>
|
| 610 |
-
<p>© 2026 FriendlyBot League. Powered by FriendlyBot.</p>
|
| 611 |
-
</footer>
|
| 612 |
-
|
| 613 |
-
<script>
|
| 614 |
-
// Smooth entrance animations and click handlers
|
| 615 |
-
document.addEventListener('DOMContentLoaded', () => {
|
| 616 |
-
const cards = document.querySelectorAll('.team-card');
|
| 617 |
-
|
| 618 |
-
cards.forEach((card, index) => {
|
| 619 |
-
// Initial animation
|
| 620 |
-
card.style.opacity = '0';
|
| 621 |
-
card.style.transform = 'translateY(20px)';
|
| 622 |
-
setTimeout(() => {
|
| 623 |
-
card.style.transition = 'all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275)';
|
| 624 |
-
card.style.opacity = '1';
|
| 625 |
-
card.style.transform = 'translateY(0)';
|
| 626 |
-
}, 100 * index);
|
| 627 |
-
|
| 628 |
-
// Click to expand
|
| 629 |
-
card.addEventListener('click', () => {
|
| 630 |
-
card.classList.toggle('expanded');
|
| 631 |
-
});
|
| 632 |
-
});
|
| 633 |
-
});
|
| 634 |
-
</script>
|
| 635 |
-
</body>
|
| 636 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lineupRenderer.js
CHANGED
|
@@ -14,21 +14,17 @@ const POSITION_COORDS = {
|
|
| 14 |
// Goalkeeper
|
| 15 |
'GK': [50, 90],
|
| 16 |
// Defenders
|
| 17 |
-
'CB': [50, 72], 'CB1': [38, 72], 'CB2': [62, 72],
|
| 18 |
'LCB': [35, 72], 'RCB': [65, 72],
|
| 19 |
'LB': [15, 65], 'RB': [85, 65],
|
| 20 |
-
'LWB': [10, 55], 'RWB': [90, 55],
|
| 21 |
// Midfielders
|
| 22 |
-
'CM': [50, 50], 'CM1': [35, 50], 'CM2': [65, 50],
|
| 23 |
'LCM': [30, 50], 'RCM': [70, 50],
|
| 24 |
-
'CDM': [50, 58], '
|
| 25 |
-
'
|
| 26 |
-
'LM': [12, 50], 'RM': [88, 50],
|
| 27 |
// Forwards
|
| 28 |
'LW': [18, 30], 'RW': [82, 30],
|
| 29 |
-
'
|
| 30 |
-
'ST': [50, 20], 'ST1': [38, 20], 'ST2': [62, 20], 'ST3': [50, 15],
|
| 31 |
-
'CF': [50, 32],
|
| 32 |
};
|
| 33 |
|
| 34 |
/**
|
|
@@ -151,40 +147,16 @@ function drawPitch(ctx, W, H) {
|
|
| 151 |
/**
|
| 152 |
* Render the lineup as a PNG image buffer
|
| 153 |
* @param {Map} lineup - Map of posKey -> [userId, ...]
|
| 154 |
-
* @param {string}
|
| 155 |
* @param {Array} formation - Array of [posKey, posLabel]
|
| 156 |
* @param {object} client - Discord client for fetching user data
|
| 157 |
-
* @param {boolean} flipY - If true, flip Y coordinates (for opposing team view)
|
| 158 |
* @returns {Promise<Buffer>} PNG image buffer
|
| 159 |
*/
|
| 160 |
-
async function renderLineupImage(lineup,
|
| 161 |
const PITCH_W = 900;
|
| 162 |
const SIDEBAR_W = 280;
|
| 163 |
const W = PITCH_W + SIDEBAR_W;
|
| 164 |
const H = 620;
|
| 165 |
-
|
| 166 |
-
// 1. Pre-fetch all user data and avatars in parallel to speed up rendering
|
| 167 |
-
const allUserIds = new Set();
|
| 168 |
-
for (const players of lineup.values()) {
|
| 169 |
-
players.forEach(id => allUserIds.add(id));
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
const userDataMap = new Map();
|
| 173 |
-
if (client) {
|
| 174 |
-
await Promise.all(Array.from(allUserIds).map(async (uid) => {
|
| 175 |
-
try {
|
| 176 |
-
const user = await client.users.fetch(uid);
|
| 177 |
-
const avatarUrl = user.displayAvatarURL({ extension: 'png', size: 128 });
|
| 178 |
-
const imgBuf = await downloadImage(avatarUrl);
|
| 179 |
-
const img = await loadImage(imgBuf);
|
| 180 |
-
userDataMap.set(uid, { user, img });
|
| 181 |
-
} catch (e) {
|
| 182 |
-
userDataMap.set(uid, { user: null, img: null });
|
| 183 |
-
}
|
| 184 |
-
}));
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
// --- Draw the content ---
|
| 188 |
const canvas = createCanvas(W, H);
|
| 189 |
const ctx = canvas.getContext('2d');
|
| 190 |
|
|
@@ -224,7 +196,7 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 224 |
ctx.fillStyle = '#ffffff';
|
| 225 |
ctx.font = 'bold 16px Arial, sans-serif';
|
| 226 |
ctx.textAlign = 'center';
|
| 227 |
-
ctx.fillText(`LINEUP — ${
|
| 228 |
ctx.restore();
|
| 229 |
|
| 230 |
// Extract subs and draw them
|
|
@@ -241,26 +213,33 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 241 |
// Draw subs list
|
| 242 |
let subY = 70;
|
| 243 |
for (const sub of subs) {
|
| 244 |
-
if (subY > H - 50) break;
|
| 245 |
|
|
|
|
| 246 |
const avatarSize = 32;
|
| 247 |
const avatarRadius = avatarSize / 2;
|
| 248 |
const x = 20;
|
| 249 |
const y = subY;
|
| 250 |
|
| 251 |
-
const data = userDataMap.get(sub.userId);
|
| 252 |
ctx.save();
|
| 253 |
-
if (
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
ctx.restore();
|
| 266 |
|
|
@@ -273,8 +252,11 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 273 |
|
| 274 |
// Username
|
| 275 |
let displayName = "Player";
|
| 276 |
-
if (
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
ctx.fillStyle = '#ffffff';
|
|
@@ -298,7 +280,7 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 298 |
ctx.textAlign = 'center';
|
| 299 |
ctx.fillText(sub.posLabel, pillX + posTextW / 2, y + avatarRadius);
|
| 300 |
|
| 301 |
-
subY += 45;
|
| 302 |
}
|
| 303 |
if (subs.length === 0) {
|
| 304 |
ctx.fillStyle = 'rgba(255,255,255,0.5)';
|
|
@@ -307,107 +289,126 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 307 |
ctx.fillText('No substitutes yet', SIDEBAR_W / 2, subY + 20);
|
| 308 |
}
|
| 309 |
|
| 310 |
-
//
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
for (const [posKey, posLabel] of formation) {
|
| 315 |
-
const coords = POSITION_COORDS[posKey];
|
| 316 |
-
if (!coords) continue;
|
| 317 |
-
|
| 318 |
-
const x = SIDEBAR_W + (coords[0] / 100) * PITCH_W;
|
| 319 |
-
const y = flipY ? ((100 - coords[1]) / 100) * H : (coords[1] / 100) * H;
|
| 320 |
-
const players = lineup.get(posKey) || [];
|
| 321 |
-
|
| 322 |
-
if (players.length > 0) {
|
| 323 |
-
ctx.save();
|
| 324 |
-
ctx.shadowColor = '#00ff88';
|
| 325 |
-
ctx.shadowBlur = 18;
|
| 326 |
-
ctx.beginPath();
|
| 327 |
-
ctx.arc(x, y, avatarRadius + 4, 0, Math.PI * 2);
|
| 328 |
-
ctx.fillStyle = 'rgba(0,255,136,0.3)';
|
| 329 |
-
ctx.fill();
|
| 330 |
-
ctx.restore();
|
| 331 |
-
}
|
| 332 |
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
ctx.clip();
|
| 342 |
-
ctx.drawImage(data.img, x - avatarRadius, y - avatarRadius, avatarSize, avatarSize);
|
| 343 |
-
ctx.restore();
|
| 344 |
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
ctx.stroke();
|
| 358 |
-
ctx.fillStyle = '#ffffff';
|
| 359 |
-
ctx.font = 'bold 16px Arial, sans-serif';
|
| 360 |
-
ctx.textAlign = 'center';
|
| 361 |
-
ctx.textBaseline = 'middle';
|
| 362 |
-
ctx.fillText('?', x, y);
|
| 363 |
-
}
|
| 364 |
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
ctx.textAlign = 'center';
|
| 371 |
-
|
| 372 |
-
const pillW = textWidth + 12;
|
| 373 |
-
const pillH = 16;
|
| 374 |
|
| 375 |
-
|
| 376 |
-
|
|
|
|
|
|
|
| 377 |
ctx.fill();
|
| 378 |
|
| 379 |
ctx.fillStyle = '#ffffff';
|
| 380 |
-
ctx.
|
| 381 |
-
ctx.fillText(truncated, x, labelY);
|
| 382 |
-
}
|
| 383 |
-
} else {
|
| 384 |
-
ctx.beginPath();
|
| 385 |
-
ctx.arc(x, y, avatarRadius, 0, Math.PI * 2);
|
| 386 |
-
ctx.fillStyle = 'rgba(0,0,0,0.35)';
|
| 387 |
-
ctx.fill();
|
| 388 |
-
ctx.setLineDash([4, 4]);
|
| 389 |
-
ctx.strokeStyle = 'rgba(255,255,255,0.5)';
|
| 390 |
-
ctx.lineWidth = 1.5;
|
| 391 |
-
ctx.stroke();
|
| 392 |
-
ctx.setLineDash([]);
|
| 393 |
}
|
| 394 |
|
| 395 |
-
const posLabelY = flipY
|
| 396 |
-
? (players.length > 0 ? y + avatarRadius + 10 : y + avatarRadius + 8)
|
| 397 |
-
: (players.length > 0 ? y - avatarRadius - 10 : y - avatarRadius - 8);
|
| 398 |
-
ctx.font = 'bold 12px Arial, sans-serif';
|
| 399 |
-
ctx.textAlign = 'center';
|
| 400 |
-
ctx.textBaseline = 'middle';
|
| 401 |
-
|
| 402 |
-
const posTextW = ctx.measureText(posLabel).width + 10;
|
| 403 |
-
roundRect(ctx, x - posTextW / 2, posLabelY - 8, posTextW, 16, 3);
|
| 404 |
-
ctx.fillStyle = players.length > 0 ? 'rgba(88,101,242,0.9)' : 'rgba(100,100,100,0.8)';
|
| 405 |
-
ctx.fill();
|
| 406 |
-
|
| 407 |
-
ctx.fillStyle = '#ffffff';
|
| 408 |
-
ctx.fillText(posLabel, x, posLabelY);
|
| 409 |
-
}
|
| 410 |
-
|
| 411 |
// 4. Footer watermark
|
| 412 |
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
| 413 |
ctx.fillRect(0, H - 22, W, 22);
|
|
@@ -425,9 +426,9 @@ async function renderLineupImage(lineup, title, formation, client, flipY = false
|
|
| 425 |
/**
|
| 426 |
* Create a Discord AttachmentBuilder from the rendered lineup
|
| 427 |
*/
|
| 428 |
-
async function createLineupAttachment(lineup,
|
| 429 |
-
const buffer = await renderLineupImage(lineup,
|
| 430 |
return new AttachmentBuilder(buffer, { name: 'lineup.png' });
|
| 431 |
}
|
| 432 |
|
| 433 |
-
module.exports = { renderLineupImage, createLineupAttachment };
|
|
|
|
| 14 |
// Goalkeeper
|
| 15 |
'GK': [50, 90],
|
| 16 |
// Defenders
|
| 17 |
+
'CB': [50, 72], 'CB1': [38, 72], 'CB2': [62, 72],
|
| 18 |
'LCB': [35, 72], 'RCB': [65, 72],
|
| 19 |
'LB': [15, 65], 'RB': [85, 65],
|
|
|
|
| 20 |
// Midfielders
|
| 21 |
+
'CM': [50, 50], 'CM1': [35, 50], 'CM2': [65, 50],
|
| 22 |
'LCM': [30, 50], 'RCM': [70, 50],
|
| 23 |
+
'CDM': [50, 58], 'CAM': [50, 38],
|
| 24 |
+
'LM': [15, 50], 'RM': [85, 50],
|
|
|
|
| 25 |
// Forwards
|
| 26 |
'LW': [18, 30], 'RW': [82, 30],
|
| 27 |
+
'ST': [50, 20], 'ST1': [38, 20], 'ST2': [62, 20],
|
|
|
|
|
|
|
| 28 |
};
|
| 29 |
|
| 30 |
/**
|
|
|
|
| 147 |
/**
|
| 148 |
* Render the lineup as a PNG image buffer
|
| 149 |
* @param {Map} lineup - Map of posKey -> [userId, ...]
|
| 150 |
+
* @param {string} formKey - Formation key (e.g. "3-1-2")
|
| 151 |
* @param {Array} formation - Array of [posKey, posLabel]
|
| 152 |
* @param {object} client - Discord client for fetching user data
|
|
|
|
| 153 |
* @returns {Promise<Buffer>} PNG image buffer
|
| 154 |
*/
|
| 155 |
+
async function renderLineupImage(lineup, formKey, formation, client) {
|
| 156 |
const PITCH_W = 900;
|
| 157 |
const SIDEBAR_W = 280;
|
| 158 |
const W = PITCH_W + SIDEBAR_W;
|
| 159 |
const H = 620;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
const canvas = createCanvas(W, H);
|
| 161 |
const ctx = canvas.getContext('2d');
|
| 162 |
|
|
|
|
| 196 |
ctx.fillStyle = '#ffffff';
|
| 197 |
ctx.font = 'bold 16px Arial, sans-serif';
|
| 198 |
ctx.textAlign = 'center';
|
| 199 |
+
ctx.fillText(`LINEUP — ${formKey.toUpperCase()}`, PITCH_W / 2, 24);
|
| 200 |
ctx.restore();
|
| 201 |
|
| 202 |
// Extract subs and draw them
|
|
|
|
| 213 |
// Draw subs list
|
| 214 |
let subY = 70;
|
| 215 |
for (const sub of subs) {
|
| 216 |
+
if (subY > H - 50) break; // prevent overflowing
|
| 217 |
|
| 218 |
+
// Avatar
|
| 219 |
const avatarSize = 32;
|
| 220 |
const avatarRadius = avatarSize / 2;
|
| 221 |
const x = 20;
|
| 222 |
const y = subY;
|
| 223 |
|
|
|
|
| 224 |
ctx.save();
|
| 225 |
+
if (client) {
|
| 226 |
+
try {
|
| 227 |
+
const user = await client.users.fetch(sub.userId);
|
| 228 |
+
const avatarUrl = user.displayAvatarURL({ extension: 'png', size: 64 });
|
| 229 |
+
const imgBuf = await downloadImage(avatarUrl);
|
| 230 |
+
const img = await loadImage(imgBuf);
|
| 231 |
+
|
| 232 |
+
ctx.beginPath();
|
| 233 |
+
ctx.arc(x + avatarRadius, y + avatarRadius, avatarRadius, 0, Math.PI * 2);
|
| 234 |
+
ctx.closePath();
|
| 235 |
+
ctx.clip();
|
| 236 |
+
ctx.drawImage(img, x, y, avatarSize, avatarSize);
|
| 237 |
+
} catch (e) {
|
| 238 |
+
ctx.beginPath();
|
| 239 |
+
ctx.arc(x + avatarRadius, y + avatarRadius, avatarRadius, 0, Math.PI * 2);
|
| 240 |
+
ctx.fillStyle = '#5865F2';
|
| 241 |
+
ctx.fill();
|
| 242 |
+
}
|
| 243 |
}
|
| 244 |
ctx.restore();
|
| 245 |
|
|
|
|
| 252 |
|
| 253 |
// Username
|
| 254 |
let displayName = "Player";
|
| 255 |
+
if (client) {
|
| 256 |
+
try {
|
| 257 |
+
const user = await client.users.fetch(sub.userId);
|
| 258 |
+
displayName = user.globalName || user.username;
|
| 259 |
+
} catch(e) {}
|
| 260 |
}
|
| 261 |
|
| 262 |
ctx.fillStyle = '#ffffff';
|
|
|
|
| 280 |
ctx.textAlign = 'center';
|
| 281 |
ctx.fillText(sub.posLabel, pillX + posTextW / 2, y + avatarRadius);
|
| 282 |
|
| 283 |
+
subY += 45; // Space for next sub
|
| 284 |
}
|
| 285 |
if (subs.length === 0) {
|
| 286 |
ctx.fillStyle = 'rgba(255,255,255,0.5)';
|
|
|
|
| 289 |
ctx.fillText('No substitutes yet', SIDEBAR_W / 2, subY + 20);
|
| 290 |
}
|
| 291 |
|
| 292 |
+
// 4. Draw players at their positions
|
| 293 |
+
const avatarSize = 48;
|
| 294 |
+
const avatarRadius = avatarSize / 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
+
for (const [posKey, posLabel] of formation) {
|
| 297 |
+
const coords = POSITION_COORDS[posKey];
|
| 298 |
+
if (!coords) continue;
|
| 299 |
|
| 300 |
+
// Shift X by SIDEBAR_W
|
| 301 |
+
const x = SIDEBAR_W + (coords[0] / 100) * PITCH_W;
|
| 302 |
+
const y = (coords[1] / 100) * H;
|
| 303 |
+
const players = lineup.get(posKey) || [];
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
+
// Draw position marker (glow ring)
|
| 306 |
+
if (players.length > 0) {
|
| 307 |
+
// Filled slot glow
|
| 308 |
+
ctx.save();
|
| 309 |
+
ctx.shadowColor = '#00ff88';
|
| 310 |
+
ctx.shadowBlur = 18;
|
| 311 |
+
ctx.beginPath();
|
| 312 |
+
ctx.arc(x, y, avatarRadius + 4, 0, Math.PI * 2);
|
| 313 |
+
ctx.fillStyle = 'rgba(0,255,136,0.3)';
|
| 314 |
+
ctx.fill();
|
| 315 |
+
ctx.restore();
|
| 316 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
+
// Draw avatar or empty slot
|
| 319 |
+
if (players.length > 0 && client) {
|
| 320 |
+
const userId = players[0];
|
| 321 |
+
try {
|
| 322 |
+
const user = await client.users.fetch(userId);
|
| 323 |
+
const avatarUrl = user.displayAvatarURL({ extension: 'png', size: 128 });
|
| 324 |
+
const imgBuf = await downloadImage(avatarUrl);
|
| 325 |
+
const img = await loadImage(imgBuf);
|
| 326 |
+
|
| 327 |
+
// Clip circle for avatar
|
| 328 |
+
ctx.save();
|
| 329 |
+
ctx.beginPath();
|
| 330 |
+
ctx.arc(x, y, avatarRadius, 0, Math.PI * 2);
|
| 331 |
+
ctx.closePath();
|
| 332 |
+
ctx.clip();
|
| 333 |
+
ctx.drawImage(img, x - avatarRadius, y - avatarRadius, avatarSize, avatarSize);
|
| 334 |
+
ctx.restore();
|
| 335 |
+
|
| 336 |
+
// Border ring
|
| 337 |
+
ctx.beginPath();
|
| 338 |
+
ctx.arc(x, y, avatarRadius + 2, 0, Math.PI * 2);
|
| 339 |
+
ctx.strokeStyle = '#ffffff';
|
| 340 |
+
ctx.lineWidth = 2.5;
|
| 341 |
+
ctx.stroke();
|
| 342 |
+
|
| 343 |
+
} catch (e) {
|
| 344 |
+
// Fallback: draw a filled circle with initials
|
| 345 |
+
ctx.beginPath();
|
| 346 |
+
ctx.arc(x, y, avatarRadius, 0, Math.PI * 2);
|
| 347 |
+
ctx.fillStyle = '#5865F2';
|
| 348 |
+
ctx.fill();
|
| 349 |
+
ctx.strokeStyle = '#ffffff';
|
| 350 |
+
ctx.lineWidth = 2;
|
| 351 |
+
ctx.stroke();
|
| 352 |
+
|
| 353 |
+
ctx.fillStyle = '#ffffff';
|
| 354 |
+
ctx.font = 'bold 16px Arial, sans-serif';
|
| 355 |
+
ctx.textAlign = 'center';
|
| 356 |
+
ctx.textBaseline = 'middle';
|
| 357 |
+
ctx.fillText('?', x, y);
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
// Username label below avatar
|
| 361 |
+
try {
|
| 362 |
+
const user = await client.users.fetch(players[0]);
|
| 363 |
+
const displayName = user.globalName || user.username;
|
| 364 |
+
const truncated = displayName.length > 10 ? displayName.slice(0, 9) + '…' : displayName;
|
| 365 |
+
|
| 366 |
+
// Label background pill
|
| 367 |
+
const labelY = y + avatarRadius + 14;
|
| 368 |
+
ctx.font = 'bold 11px Arial, sans-serif';
|
| 369 |
+
ctx.textAlign = 'center';
|
| 370 |
+
const textWidth = ctx.measureText(truncated).width;
|
| 371 |
+
const pillW = textWidth + 12;
|
| 372 |
+
const pillH = 16;
|
| 373 |
+
|
| 374 |
+
roundRect(ctx, x - pillW / 2, labelY - pillH / 2, pillW, pillH, 4);
|
| 375 |
+
ctx.fillStyle = 'rgba(0,0,0,0.75)';
|
| 376 |
+
ctx.fill();
|
| 377 |
+
|
| 378 |
+
ctx.fillStyle = '#ffffff';
|
| 379 |
+
ctx.textBaseline = 'middle';
|
| 380 |
+
ctx.fillText(truncated, x, labelY);
|
| 381 |
+
} catch (e) {}
|
| 382 |
+
|
| 383 |
+
} else {
|
| 384 |
+
// Empty slot: dashed circle
|
| 385 |
+
ctx.beginPath();
|
| 386 |
+
ctx.arc(x, y, avatarRadius, 0, Math.PI * 2);
|
| 387 |
+
ctx.fillStyle = 'rgba(0,0,0,0.35)';
|
| 388 |
+
ctx.fill();
|
| 389 |
+
ctx.setLineDash([4, 4]);
|
| 390 |
+
ctx.strokeStyle = 'rgba(255,255,255,0.5)';
|
| 391 |
+
ctx.lineWidth = 1.5;
|
| 392 |
+
ctx.stroke();
|
| 393 |
+
ctx.setLineDash([]);
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Position label (always shown)
|
| 397 |
+
const posLabelY = players.length > 0 ? y - avatarRadius - 10 : y - avatarRadius - 8;
|
| 398 |
+
ctx.font = 'bold 12px Arial, sans-serif';
|
| 399 |
ctx.textAlign = 'center';
|
| 400 |
+
ctx.textBaseline = 'middle';
|
|
|
|
|
|
|
| 401 |
|
| 402 |
+
// Position tag background
|
| 403 |
+
const posTextW = ctx.measureText(posLabel).width + 10;
|
| 404 |
+
roundRect(ctx, x - posTextW / 2, posLabelY - 8, posTextW, 16, 3);
|
| 405 |
+
ctx.fillStyle = players.length > 0 ? 'rgba(88,101,242,0.9)' : 'rgba(100,100,100,0.8)';
|
| 406 |
ctx.fill();
|
| 407 |
|
| 408 |
ctx.fillStyle = '#ffffff';
|
| 409 |
+
ctx.fillText(posLabel, x, posLabelY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
}
|
| 411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
// 4. Footer watermark
|
| 413 |
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
| 414 |
ctx.fillRect(0, H - 22, W, 22);
|
|
|
|
| 426 |
/**
|
| 427 |
* Create a Discord AttachmentBuilder from the rendered lineup
|
| 428 |
*/
|
| 429 |
+
async function createLineupAttachment(lineup, formKey, formation, client) {
|
| 430 |
+
const buffer = await renderLineupImage(lineup, formKey, formation, client);
|
| 431 |
return new AttachmentBuilder(buffer, { name: 'lineup.png' });
|
| 432 |
}
|
| 433 |
|
| 434 |
+
module.exports = { renderLineupImage, createLineupAttachment };
|
lineup_persistence.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
| 1 |
-
const fs = require('fs');
|
| 2 |
-
const path = require('path');
|
| 3 |
-
const storage = require('./storage');
|
| 4 |
-
|
| 5 |
-
/**
|
| 6 |
-
* lineup_persistence.js
|
| 7 |
-
* Handles persistent storage for lineup state across bot restarts.
|
| 8 |
-
* Fixes the issue where lineups reset when the space restarts.
|
| 9 |
-
*/
|
| 10 |
-
|
| 11 |
-
const LINEUP_DATA_FILE = path.join(storage.PERSISTENT_DIR, 'lineup_persistence.json');
|
| 12 |
-
|
| 13 |
-
let guildLineups = new Map();
|
| 14 |
-
let guildSelectedFormationA = new Map();
|
| 15 |
-
let guildSelectedFormationB = new Map();
|
| 16 |
-
// Shared formation selection map for text-based lineup (!lineup)
|
| 17 |
-
let guildSelectedFormation = new Map();
|
| 18 |
-
let lineupOwners = new Map();
|
| 19 |
-
let activeLineupMessages = new Map();
|
| 20 |
-
let managerBoards = new Map();
|
| 21 |
-
let guildCustomFormations = new Map();
|
| 22 |
-
let guildCustomFormationNames = new Map();
|
| 23 |
-
let guildPingType = new Map();
|
| 24 |
-
let guildFriendlyPingType = new Map();
|
| 25 |
-
let guildScrimMode = new Map(); // Track if lineup is in scrim mode
|
| 26 |
-
let guildLineupsB = new Map(); // Team B lineup for scrim mode
|
| 27 |
-
|
| 28 |
-
function save() {
|
| 29 |
-
try {
|
| 30 |
-
const data = {
|
| 31 |
-
guildLineups: {},
|
| 32 |
-
guildSelectedFormationA: Object.fromEntries(guildSelectedFormationA),
|
| 33 |
-
guildSelectedFormationB: Object.fromEntries(guildSelectedFormationB),
|
| 34 |
-
// Persist the shared text-based formation map as well
|
| 35 |
-
guildSelectedFormation: Object.fromEntries(guildSelectedFormation),
|
| 36 |
-
lineupOwners: Object.fromEntries(lineupOwners),
|
| 37 |
-
activeLineupMessages: Object.fromEntries(activeLineupMessages),
|
| 38 |
-
managerBoards: Object.fromEntries(managerBoards),
|
| 39 |
-
guildCustomFormations: Object.fromEntries(guildCustomFormations),
|
| 40 |
-
guildCustomFormationNames: Object.fromEntries(guildCustomFormationNames),
|
| 41 |
-
guildPingType: Object.fromEntries(guildPingType),
|
| 42 |
-
guildFriendlyPingType: Object.fromEntries(guildFriendlyPingType),
|
| 43 |
-
guildScrimMode: Object.fromEntries(guildScrimMode),
|
| 44 |
-
guildLineupsB: {}
|
| 45 |
-
};
|
| 46 |
-
|
| 47 |
-
for (const [guildId, lineupMap] of guildLineups) {
|
| 48 |
-
data.guildLineups[guildId] = Object.fromEntries(lineupMap);
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
for (const [guildId, lineupMap] of guildLineupsB) {
|
| 52 |
-
data.guildLineupsB[guildId] = Object.fromEntries(lineupMap);
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
fs.writeFileSync(LINEUP_DATA_FILE, JSON.stringify(data, null, 2));
|
| 56 |
-
// console.log('[LINEUP PERSISTENCE] State saved successfully.');
|
| 57 |
-
} catch (e) {
|
| 58 |
-
console.error('[LINEUP PERSISTENCE] Save failed:', e.message);
|
| 59 |
-
}
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
function load() {
|
| 63 |
-
if (!fs.existsSync(LINEUP_DATA_FILE)) {
|
| 64 |
-
console.log('[LINEUP PERSISTENCE] No existing persistence file found.');
|
| 65 |
-
return;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
try {
|
| 69 |
-
const raw = fs.readFileSync(LINEUP_DATA_FILE, 'utf8');
|
| 70 |
-
const data = JSON.parse(raw);
|
| 71 |
-
|
| 72 |
-
if (data.guildLineups) {
|
| 73 |
-
for (const [guildId, lineupObj] of Object.entries(data.guildLineups)) {
|
| 74 |
-
guildLineups.set(guildId, new Map(Object.entries(lineupObj)));
|
| 75 |
-
}
|
| 76 |
-
}
|
| 77 |
-
// Load shared text-based formation state if available
|
| 78 |
-
if (data.guildSelectedFormation) {
|
| 79 |
-
for (const [k, v] of Object.entries(data.guildSelectedFormation)) guildSelectedFormation.set(k, v);
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
if (data.guildSelectedFormationA) {
|
| 83 |
-
for (const [k, v] of Object.entries(data.guildSelectedFormationA)) guildSelectedFormationA.set(k, v);
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
if (data.guildSelectedFormationB) {
|
| 87 |
-
for (const [k, v] of Object.entries(data.guildSelectedFormationB)) guildSelectedFormationB.set(k, v);
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
if (data.lineupOwners) {
|
| 91 |
-
for (const [k, v] of Object.entries(data.lineupOwners)) lineupOwners.set(k, v);
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
if (data.activeLineupMessages) {
|
| 95 |
-
for (const [k, v] of Object.entries(data.activeLineupMessages)) activeLineupMessages.set(k, v);
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
if (data.managerBoards) {
|
| 99 |
-
for (const [k, v] of Object.entries(data.managerBoards)) managerBoards.set(k, v);
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
if (data.guildCustomFormations) {
|
| 103 |
-
for (const [k, v] of Object.entries(data.guildCustomFormations)) guildCustomFormations.set(k, v);
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
if (data.guildCustomFormationNames) {
|
| 107 |
-
for (const [k, v] of Object.entries(data.guildCustomFormationNames)) guildCustomFormationNames.set(k, v);
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
if (data.guildPingType) {
|
| 111 |
-
for (const [k, v] of Object.entries(data.guildPingType)) guildPingType.set(k, v);
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
if (data.guildFriendlyPingType) {
|
| 115 |
-
for (const [k, v] of Object.entries(data.guildFriendlyPingType)) guildFriendlyPingType.set(k, v);
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
if (data.guildScrimMode) {
|
| 119 |
-
for (const [k, v] of Object.entries(data.guildScrimMode)) guildScrimMode.set(k, v === "true" || v === true);
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
if (data.guildLineupsB) {
|
| 123 |
-
for (const [guildId, lineupObj] of Object.entries(data.guildLineupsB)) {
|
| 124 |
-
guildLineupsB.set(guildId, new Map(Object.entries(lineupObj)));
|
| 125 |
-
}
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
console.log('[LINEUP PERSISTENCE] Data loaded successfully.');
|
| 129 |
-
} catch (e) {
|
| 130 |
-
console.error('[LINEUP PERSISTENCE] Load failed:', e.message);
|
| 131 |
-
}
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
// Initial load
|
| 135 |
-
load();
|
| 136 |
-
|
| 137 |
-
module.exports = {
|
| 138 |
-
guildLineups, guildLineupsB, guildSelectedFormationA, guildSelectedFormationB, guildSelectedFormation, lineupOwners, activeLineupMessages, managerBoards, guildCustomFormations, guildCustomFormationNames, guildPingType, guildFriendlyPingType, guildScrimMode, save
|
| 139 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
network_fix.js
CHANGED
|
@@ -1,35 +1,59 @@
|
|
|
|
|
|
|
|
| 1 |
const dns = require('dns');
|
|
|
|
| 2 |
|
| 3 |
/**
|
| 4 |
-
*
|
| 5 |
-
*
|
| 6 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
function applyAdvancedFixes() {
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
-
function getDispatcher() { return this._dispatcher; }
|
| 23 |
function rotateEndpoint() {
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
console.error("[NETWORK FIX] Error rotating endpoint:", e.message);
|
| 31 |
-
}
|
| 32 |
}
|
| 33 |
-
function getTargetDomain() { return 'discord.com'; }
|
| 34 |
|
| 35 |
-
module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain
|
|
|
|
| 1 |
+
const https = require('https');
|
| 2 |
+
const http = require('http');
|
| 3 |
const dns = require('dns');
|
| 4 |
+
const { Agent, setGlobalDispatcher } = require('undici');
|
| 5 |
|
| 6 |
/**
|
| 7 |
+
* Professional Network Resilience Engine
|
| 8 |
+
* Implements a stealth failover system for restricted environments.
|
| 9 |
*/
|
| 10 |
+
|
| 11 |
+
// Use official Discord domains only (explicitly excludes legacy discordapp.com).
|
| 12 |
+
const FALLBACK_DOMAINS = ['discord.com', 'canary.discord.com', 'ptb.discord.com'];
|
| 13 |
+
let active_index = 0;
|
| 14 |
+
|
| 15 |
function applyAdvancedFixes() {
|
| 16 |
+
const target = FALLBACK_DOMAINS[active_index];
|
| 17 |
+
console.log(`[NETWORK] Stealth Failover Active: Using ${target} bridge.`);
|
| 18 |
+
|
| 19 |
+
// 1. Force IPv4 Priority (Standard for HF Stability)
|
| 20 |
+
if (dns.setDefaultResultOrder) dns.setDefaultResultOrder('ipv4first');
|
| 21 |
+
|
| 22 |
+
// 2. Low-Level DNS Hijacking
|
| 23 |
+
// This ensures that even if a library hardcodes 'discord.com', it gets the IP of our bridge.
|
| 24 |
+
const originalLookup = dns.lookup;
|
| 25 |
+
dns.lookup = function(hostname, options, callback) {
|
| 26 |
+
if (typeof options === 'function') { callback = options; options = {}; }
|
| 27 |
+
let h = hostname;
|
| 28 |
+
if (hostname.includes('discord.com') && !hostname.includes('gateway') && !hostname.includes(target)) {
|
| 29 |
+
h = target;
|
| 30 |
+
}
|
| 31 |
+
return originalLookup(h, options, callback);
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
// 3. Optimized Connection Pooling
|
| 35 |
+
const agent = new Agent({
|
| 36 |
+
connect: {
|
| 37 |
+
timeout: 30000,
|
| 38 |
+
family: 4,
|
| 39 |
+
servername: target // Critical for TLS Handshake consistency
|
| 40 |
+
},
|
| 41 |
+
pipelining: 1,
|
| 42 |
+
keepAliveTimeout: 60000
|
| 43 |
+
});
|
| 44 |
+
setGlobalDispatcher(agent);
|
| 45 |
+
|
| 46 |
+
// 4. Legacy Module Support
|
| 47 |
+
https.globalAgent.options.family = 4;
|
| 48 |
}
|
| 49 |
|
|
|
|
| 50 |
function rotateEndpoint() {
|
| 51 |
+
active_index = (active_index + 1) % FALLBACK_DOMAINS.length;
|
| 52 |
+
applyAdvancedFixes();
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function getTargetDomain() {
|
| 56 |
+
return FALLBACK_DOMAINS[active_index];
|
|
|
|
|
|
|
| 57 |
}
|
|
|
|
| 58 |
|
| 59 |
+
module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain };
|
package.json
CHANGED
|
@@ -1,22 +1,16 @@
|
|
| 1 |
{
|
| 2 |
-
"name": "friendlybot-
|
| 3 |
-
"version": "
|
| 4 |
-
"description": "
|
| 5 |
"main": "index.js",
|
| 6 |
"scripts": {
|
| 7 |
-
"start": "node index.js"
|
| 8 |
-
"dev": "node index.js"
|
| 9 |
},
|
| 10 |
"dependencies": {
|
|
|
|
| 11 |
"discord.js": "^14.14.1",
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"undici": "^6.0.0",
|
| 16 |
-
"node-fetch": "^2.7.0",
|
| 17 |
-
"@napi-rs/canvas": "^0.1.50"
|
| 18 |
-
},
|
| 19 |
-
"engines": {
|
| 20 |
-
"node": ">=18.0.0"
|
| 21 |
}
|
| 22 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"name": "friendlybot-node",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "FriendlyBot ported to Node.js for maximum performance",
|
| 5 |
"main": "index.js",
|
| 6 |
"scripts": {
|
| 7 |
+
"start": "node index.js"
|
|
|
|
| 8 |
},
|
| 9 |
"dependencies": {
|
| 10 |
+
"@napi-rs/canvas": "^0.1.97",
|
| 11 |
"discord.js": "^14.14.1",
|
| 12 |
+
"dotenv": "^16.4.5",
|
| 13 |
+
"express": "^4.18.3",
|
| 14 |
+
"node-fetch": "^2.7.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
+
}
|
postinstall.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
// postinstall.js - Ensures native modules compile correctly on Linux/HF
|
| 2 |
-
const { execSync } = require("child_process");
|
| 3 |
-
const os = require("os");
|
| 4 |
-
|
| 5 |
-
console.log("[INSTALL] Checking environment...");
|
| 6 |
-
|
| 7 |
-
// If running on Linux (like HF Spaces), ensure build tools are conceptually ready
|
| 8 |
-
// Note: HF Spaces usually has build-tools installed, but this is a safe guard.
|
| 9 |
-
if (os.platform() === 'linux') {
|
| 10 |
-
console.log("[INSTALL] Linux environment detected. Ensuring native modules are ready...");
|
| 11 |
-
try {
|
| 12 |
-
// Rebuild better-sqlite3 if needed
|
| 13 |
-
execSync("npm rebuild better-sqlite3", { stdio: "inherit" });
|
| 14 |
-
console.log("[INSTALL] Native modules rebuilt successfully.");
|
| 15 |
-
} catch (e) {
|
| 16 |
-
console.warn("[INSTALL] Warning: Could not rebuild native modules. If the bot fails, ensure 'build-essential' is installed on the host.");
|
| 17 |
-
}
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
premium.html
DELETED
|
@@ -1,179 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>FriendlyBot — Premium</title>
|
| 7 |
-
<link rel="icon" href="/logo.png" />
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #0a0a1a; --surface: #12122a; --border: rgba(255,255,255,0.08);
|
| 12 |
-
--text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
|
| 13 |
-
--accent: #5865F2; --radius: 16px;
|
| 14 |
-
}
|
| 15 |
-
* { box-sizing: border-box; margin:0; padding:0; }
|
| 16 |
-
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
|
| 17 |
-
header { max-width: 1000px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
|
| 18 |
-
h1 { font-size: 28px; font-weight: 700; }
|
| 19 |
-
.btn {
|
| 20 |
-
display: inline-block; padding: 10px 20px; background: var(--accent);
|
| 21 |
-
color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px;
|
| 22 |
-
}
|
| 23 |
-
.container { max-width: 1000px; margin: 0 auto; }
|
| 24 |
-
.hero {
|
| 25 |
-
background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
|
| 26 |
-
color: #000; padding: 40px; border-radius: var(--radius); margin-bottom: 30px; text-align: center;
|
| 27 |
-
}
|
| 28 |
-
.hero h2 { font-size: 28px; font-weight: 800; margin-bottom: 10px; }
|
| 29 |
-
.hero p { font-size: 16px; opacity: 0.8; }
|
| 30 |
-
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-bottom: 30px; }
|
| 31 |
-
.card {
|
| 32 |
-
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
|
| 33 |
-
border: 1px solid var(--border); border-radius: var(--radius);
|
| 34 |
-
padding: 24px; transition: all 0.25s;
|
| 35 |
-
}
|
| 36 |
-
.card:hover { border-color: var(--gold); transform: translateY(-3px); }
|
| 37 |
-
.card .icon { font-size: 32px; margin-bottom: 12px; }
|
| 38 |
-
.card h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
|
| 39 |
-
.card p { font-size: 14px; color: var(--text-dim); line-height: 1.6; }
|
| 40 |
-
.status {
|
| 41 |
-
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
|
| 42 |
-
border: 1px solid var(--border); border-radius: var(--radius);
|
| 43 |
-
padding: 24px; margin-bottom: 30px; display: flex; align-items: center; gap: 16px;
|
| 44 |
-
}
|
| 45 |
-
.status .badge {
|
| 46 |
-
padding: 8px 20px; border-radius: 100px; font-weight: 700; font-size: 14px;
|
| 47 |
-
}
|
| 48 |
-
.badge.active { background: rgba(255,215,0,0.2); color: var(--gold); border: 1px solid var(--gold); }
|
| 49 |
-
.badge.inactive { background: rgba(255,255,255,0.05); color: var(--text-dim); border: 1px solid var(--border); }
|
| 50 |
-
.user-row { display: flex; align-items: center; gap: 12px; }
|
| 51 |
-
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: white; }
|
| 52 |
-
.user-avatar img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
|
| 53 |
-
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
|
| 54 |
-
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); }
|
| 55 |
-
th { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
|
| 56 |
-
@media (max-width: 700px) { .features { grid-template-columns: 1fr; } }
|
| 57 |
-
</style>
|
| 58 |
-
</head>
|
| 59 |
-
<body>
|
| 60 |
-
<header>
|
| 61 |
-
<h1>⭐ Premium</h1>
|
| 62 |
-
<a href="/" class="btn">Back to Dashboard</a>
|
| 63 |
-
</header>
|
| 64 |
-
<div class="container">
|
| 65 |
-
<div class="hero">
|
| 66 |
-
<h2>⭐ FriendlyBot Premium</h2>
|
| 67 |
-
<p>Unlock exclusive features by winning a league match. Premium is granted automatically when you record a win with <code>!win</code>.</p>
|
| 68 |
-
</div>
|
| 69 |
-
<div class="status" id="status">
|
| 70 |
-
<div class="badge inactive" id="premium-badge">Checking...</div>
|
| 71 |
-
<span id="premium-text">Loading your premium status...</span>
|
| 72 |
-
</div>
|
| 73 |
-
<div class="features" id="features">
|
| 74 |
-
<div class="card locked" data-feature="0">
|
| 75 |
-
<div class="icon">📊</div>
|
| 76 |
-
<h3>Advanced Stats & Analytics</h3>
|
| 77 |
-
<p>Track goals, assists, clean sheets, and weekly leaderboards for every player.</p>
|
| 78 |
-
</div>
|
| 79 |
-
<div class="card locked" data-feature="1">
|
| 80 |
-
<div class="icon">📅</div>
|
| 81 |
-
<h3>Match Scheduling & Reminders</h3>
|
| 82 |
-
<p>Auto-post scheduled matches with DM reminders 60 minutes before kickoff.</p>
|
| 83 |
-
</div>
|
| 84 |
-
<div class="card locked" data-feature="2">
|
| 85 |
-
<div class="icon">🎴</div>
|
| 86 |
-
<h3>Player Profile Cards</h3>
|
| 87 |
-
<p>Advanced <code>profileimage</code> with extra stats and custom backgrounds.</p>
|
| 88 |
-
</div>
|
| 89 |
-
<div class="card locked" data-feature="3">
|
| 90 |
-
<div class="icon">🔧</div>
|
| 91 |
-
<h3>Custom Command Aliases</h3>
|
| 92 |
-
<p>Rename bot commands to fit your server (e.g. <code>!ff</code> for <code>!friendly</code>).</p>
|
| 93 |
-
</div>
|
| 94 |
-
</div>
|
| 95 |
-
<div class="card" style="padding:24px">
|
| 96 |
-
<h3>🏆 Premium Users</h3>
|
| 97 |
-
<table>
|
| 98 |
-
<thead><tr><th>User</th><th>Since</th><th>Reason</th></tr></thead>
|
| 99 |
-
<tbody id="premium-list"><tr><td colspan="3">Loading...</td></tr></tbody>
|
| 100 |
-
</table>
|
| 101 |
-
</div>
|
| 102 |
-
</div>
|
| 103 |
-
<script>
|
| 104 |
-
async function fetchUser(userId) {
|
| 105 |
-
try {
|
| 106 |
-
const r = await fetch(`https://cdn.discordapp.com/embed/avatars/0.png`); // placeholder — we use ID
|
| 107 |
-
return null; // We use a fallback below
|
| 108 |
-
} catch(e) { return null; }
|
| 109 |
-
}
|
| 110 |
-
async function load() {
|
| 111 |
-
const statusEl = document.getElementById('premium-badge');
|
| 112 |
-
const textEl = document.getElementById('premium-text');
|
| 113 |
-
const listEl = document.getElementById('premium-list');
|
| 114 |
-
const cards = document.querySelectorAll('#features .card');
|
| 115 |
-
try {
|
| 116 |
-
// Check login status first to show user-specific premium status
|
| 117 |
-
let userPremium = false;
|
| 118 |
-
try {
|
| 119 |
-
const authR = await fetch('/api/me');
|
| 120 |
-
const authData = await authR.json();
|
| 121 |
-
if (authData.loggedIn) {
|
| 122 |
-
const premiumR = await fetch('/api/premium');
|
| 123 |
-
const premiumData = await premiumR.json();
|
| 124 |
-
userPremium = premiumData.premium;
|
| 125 |
-
}
|
| 126 |
-
} catch (e) { /* not logged in, that's fine */ }
|
| 127 |
-
|
| 128 |
-
if (userPremium) {
|
| 129 |
-
statusEl.className = 'badge active';
|
| 130 |
-
statusEl.textContent = '⭐ ACTIVE';
|
| 131 |
-
textEl.textContent = 'You have Premium access! Enjoy all features.';
|
| 132 |
-
cards.forEach(c => {
|
| 133 |
-
c.style.borderColor = 'var(--gold)';
|
| 134 |
-
c.style.opacity = '1';
|
| 135 |
-
c.classList.remove('locked');
|
| 136 |
-
c.style.cursor = 'pointer';
|
| 137 |
-
c.onclick = () => {
|
| 138 |
-
const feature = c.getAttribute('data-feature');
|
| 139 |
-
if (feature === '0') window.location.href = '/stats';
|
| 140 |
-
else if (feature === '1') window.location.href = '/scheduling';
|
| 141 |
-
else if (feature === '2') window.location.href = '/profiles';
|
| 142 |
-
else if (feature === '3') window.location.href = '/aliases';
|
| 143 |
-
};
|
| 144 |
-
});
|
| 145 |
-
} else {
|
| 146 |
-
statusEl.className = 'badge inactive';
|
| 147 |
-
statusEl.textContent = '— LOCKED';
|
| 148 |
-
textEl.textContent = 'Log in to the dashboard and win a league match with !win to unlock Premium.';
|
| 149 |
-
cards.forEach(c => { c.style.borderColor = 'var(--border)'; c.style.opacity = '0.55'; c.classList.add('locked'); });
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
// Load public premium list
|
| 153 |
-
const listR = await fetch('/api/premium/list');
|
| 154 |
-
const listData = await listR.json();
|
| 155 |
-
if (listData.list && listData.list.length > 0) {
|
| 156 |
-
listEl.innerHTML = listData.list.map(u => {
|
| 157 |
-
const date = new Date(u.grantedAt).toLocaleDateString();
|
| 158 |
-
const avatarUrl = u.avatarUrl || '';
|
| 159 |
-
const displayName = u.userTag || u.userId;
|
| 160 |
-
const initial = (displayName || '?')[0].toUpperCase();
|
| 161 |
-
const avatarHtml = avatarUrl
|
| 162 |
-
? `<img src="${avatarUrl}" onerror="this.parentElement.textContent='${initial}'" alt="">`
|
| 163 |
-
: `<span style="font-size:14px;font-weight:700">${initial}</span>`;
|
| 164 |
-
return `<tr><td><div class="user-row"><div class="user-avatar">${avatarHtml}</div><span style="font-size:13px;font-weight:500">${displayName}</span></div></td><td style="font-size:13px">${date}</td><td style="font-size:13px;color:var(--text-dim)">${u.reason || 'manual'}</td></tr>`;
|
| 165 |
-
}).join('');
|
| 166 |
-
} else {
|
| 167 |
-
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--text-dim);padding:24px">No premium users yet. Win a league match to be the first!</td></tr>';
|
| 168 |
-
}
|
| 169 |
-
} catch (e) {
|
| 170 |
-
statusEl.className = 'badge inactive';
|
| 171 |
-
statusEl.textContent = '❌ ERROR';
|
| 172 |
-
textEl.textContent = 'Could not load premium data.';
|
| 173 |
-
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--red)">Failed to load.</td></tr>';
|
| 174 |
-
}
|
| 175 |
-
}
|
| 176 |
-
load();
|
| 177 |
-
</script>
|
| 178 |
-
</body>
|
| 179 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
premiumStore.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
| 1 |
-
"use strict";
|
| 2 |
-
const fs = require("fs");
|
| 3 |
-
const path = require("path");
|
| 4 |
-
|
| 5 |
-
const dataPath = path.resolve(__dirname, "data", "premium.json");
|
| 6 |
-
const dir = path.dirname(dataPath);
|
| 7 |
-
|
| 8 |
-
let data = { premiumUsers: {}, premiumGuilds: {} };
|
| 9 |
-
|
| 10 |
-
function ensureData() {
|
| 11 |
-
try {
|
| 12 |
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
| 13 |
-
if (!fs.existsSync(dataPath)) fs.writeFileSync(dataPath, JSON.stringify(data, null, 2), "utf8");
|
| 14 |
-
const raw = fs.readFileSync(dataPath, "utf8");
|
| 15 |
-
data = JSON.parse(raw);
|
| 16 |
-
if (!data.premiumUsers) data.premiumUsers = {};
|
| 17 |
-
if (!data.premiumGuilds) data.premiumGuilds = {};
|
| 18 |
-
} catch (e) {
|
| 19 |
-
console.error("[PREMIUM] Failed to load premium.json:", e.message);
|
| 20 |
-
data = { premiumUsers: {}, premiumGuilds: {} };
|
| 21 |
-
}
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
function save() {
|
| 25 |
-
try {
|
| 26 |
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
| 27 |
-
fs.writeFileSync(dataPath, JSON.stringify(data, null, 2), "utf8");
|
| 28 |
-
} catch (e) {
|
| 29 |
-
console.error("[PREMIUM] Failed to save premium.json:", e.message);
|
| 30 |
-
}
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
function isPremium(userId) {
|
| 34 |
-
ensureData();
|
| 35 |
-
const record = data.premiumUsers[userId];
|
| 36 |
-
if (!record) return false;
|
| 37 |
-
// Check expiry (null = never expires, only league winners)
|
| 38 |
-
if (record.expiresAt !== null && Date.now() > record.expiresAt) {
|
| 39 |
-
delete data.premiumUsers[userId];
|
| 40 |
-
save();
|
| 41 |
-
return false;
|
| 42 |
-
}
|
| 43 |
-
return true;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
function isPremiumGuild(guildId) {
|
| 47 |
-
ensureData();
|
| 48 |
-
const record = data.premiumGuilds[guildId];
|
| 49 |
-
if (!record) return false;
|
| 50 |
-
if (record.expiresAt !== null && Date.now() > record.expiresAt) {
|
| 51 |
-
delete data.premiumGuilds[guildId];
|
| 52 |
-
save();
|
| 53 |
-
return false;
|
| 54 |
-
}
|
| 55 |
-
return true;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
function grantUser(userId, reason = "manual", expiresAt = null) {
|
| 59 |
-
ensureData();
|
| 60 |
-
data.premiumUsers[userId] = { grantedAt: Date.now(), reason, expiresAt };
|
| 61 |
-
save();
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
function revokeUser(userId) {
|
| 65 |
-
ensureData();
|
| 66 |
-
delete data.premiumUsers[userId];
|
| 67 |
-
save();
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
function grantGuild(guildId, reason = "manual", expiresAt = null) {
|
| 71 |
-
ensureData();
|
| 72 |
-
data.premiumGuilds[guildId] = { grantedAt: Date.now(), reason, expiresAt };
|
| 73 |
-
save();
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
function revokeGuild(guildId) {
|
| 77 |
-
ensureData();
|
| 78 |
-
delete data.premiumGuilds[guildId];
|
| 79 |
-
save();
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
function getAllPremiumUsers() {
|
| 83 |
-
ensureData();
|
| 84 |
-
return { ...data.premiumUsers };
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
function getAllPremiumGuilds() {
|
| 88 |
-
ensureData();
|
| 89 |
-
return { ...data.premiumGuilds };
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
// Load on init
|
| 93 |
-
ensureData();
|
| 94 |
-
|
| 95 |
-
module.exports = {
|
| 96 |
-
isPremium,
|
| 97 |
-
isPremiumGuild,
|
| 98 |
-
grantUser,
|
| 99 |
-
revokeUser,
|
| 100 |
-
grantGuild,
|
| 101 |
-
revokeGuild,
|
| 102 |
-
getAllPremiumUsers,
|
| 103 |
-
getAllPremiumGuilds,
|
| 104 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
privacy.html
DELETED
|
@@ -1,66 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Privacy Policy - FriendlyBot</title>
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
| 8 |
-
<style>
|
| 9 |
-
:root {
|
| 10 |
-
--primary: #10b981;
|
| 11 |
-
--bg: #0f172a;
|
| 12 |
-
--card: #1e293b;
|
| 13 |
-
--text: #f8fafc;
|
| 14 |
-
--text-muted: #94a3b8;
|
| 15 |
-
}
|
| 16 |
-
body {
|
| 17 |
-
font-family: 'Inter', sans-serif;
|
| 18 |
-
background-color: var(--bg);
|
| 19 |
-
color: var(--text);
|
| 20 |
-
line-height: 1.6;
|
| 21 |
-
margin: 0;
|
| 22 |
-
padding: 2rem;
|
| 23 |
-
display: flex;
|
| 24 |
-
justify-content: center;
|
| 25 |
-
}
|
| 26 |
-
.container {
|
| 27 |
-
max-width: 800px;
|
| 28 |
-
background: var(--card);
|
| 29 |
-
padding: 3rem;
|
| 30 |
-
border-radius: 1rem;
|
| 31 |
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 32 |
-
}
|
| 33 |
-
h1 { color: var(--primary); margin-top: 0; }
|
| 34 |
-
h2 { border-bottom: 1px solid #334155; padding-bottom: 0.5rem; margin-top: 2rem; }
|
| 35 |
-
p { color: var(--text-muted); }
|
| 36 |
-
.back-link { display: inline-block; margin-bottom: 2rem; color: var(--primary); text-decoration: none; font-weight: 600; }
|
| 37 |
-
</style>
|
| 38 |
-
</head>
|
| 39 |
-
<body>
|
| 40 |
-
<div class="container">
|
| 41 |
-
<a href="/" class="back-link">← Back to Dashboard</a>
|
| 42 |
-
<h1>Privacy Policy</h1>
|
| 43 |
-
<p>Last Updated: April 24, 2026</p>
|
| 44 |
-
|
| 45 |
-
<h2>1. Data We Collect</h2>
|
| 46 |
-
<p>FriendlyBot collects only the data necessary to provide its features:</p>
|
| 47 |
-
<ul>
|
| 48 |
-
<li><strong>Discord User IDs:</strong> To track stats (wins, goals, MOTM) and manage lineups.</li>
|
| 49 |
-
<li><strong>Discord Server IDs:</strong> To store server-specific settings and configurations.</li>
|
| 50 |
-
<li><strong>Channel IDs:</strong> To manage auto-friendly polls and message cleanup.</li>
|
| 51 |
-
</ul>
|
| 52 |
-
|
| 53 |
-
<h2>2. How We Use Data</h2>
|
| 54 |
-
<p>Data is used exclusively for internal bot functionality. We use User IDs to display player profiles and Server IDs to ensure your settings are saved correctly.</p>
|
| 55 |
-
|
| 56 |
-
<h2>3. Data Retention</h2>
|
| 57 |
-
<p>We keep match statistics and settings indefinitely unless the bot is removed from the server or a manual deletion is requested.</p>
|
| 58 |
-
|
| 59 |
-
<h2>4. Data Sharing</h2>
|
| 60 |
-
<p><strong>We do not sell or share your data with third parties.</strong> All data is stored securely on our hosting platform (Hugging Face).</p>
|
| 61 |
-
|
| 62 |
-
<h2>5. Your Rights</h2>
|
| 63 |
-
<p>Users can request their data to be deleted from our records by contacting the bot owner or support team.</p>
|
| 64 |
-
</div>
|
| 65 |
-
</body>
|
| 66 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
profiles.html
DELETED
|
@@ -1,180 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>FriendlyBot — Profile Cards</title>
|
| 7 |
-
<link rel="icon" href="/logo.png" />
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #0a0a1a; --surface: #12122a; --surface2: #1a1a3a; --border: rgba(255,255,255,0.08);
|
| 12 |
-
--text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
|
| 13 |
-
--accent: #5865F2; --radius: 16px; --red: #ED4245;
|
| 14 |
-
}
|
| 15 |
-
* { box-sizing: border-box; margin:0; padding:0; }
|
| 16 |
-
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
|
| 17 |
-
header { max-width: 800px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
|
| 18 |
-
h1 { font-size: 28px; font-weight: 700; }
|
| 19 |
-
.btn {
|
| 20 |
-
display: inline-block; padding: 10px 20px; background: var(--accent);
|
| 21 |
-
color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px; border: none; cursor: pointer;
|
| 22 |
-
}
|
| 23 |
-
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
|
| 24 |
-
.container { max-width: 800px; margin: 0 auto; }
|
| 25 |
-
.card {
|
| 26 |
-
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
|
| 27 |
-
border: 1px solid var(--border); border-radius: var(--radius);
|
| 28 |
-
padding: 32px; margin-bottom: 30px;
|
| 29 |
-
}
|
| 30 |
-
.card h2 { font-size: 20px; margin-bottom: 12px; }
|
| 31 |
-
.card p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
|
| 32 |
-
|
| 33 |
-
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
|
| 34 |
-
.theme-card {
|
| 35 |
-
background: var(--surface2); border: 2px solid transparent; border-radius: 12px; padding: 16px; cursor: pointer; transition: 0.2s;
|
| 36 |
-
}
|
| 37 |
-
.theme-card:hover { border-color: var(--accent); }
|
| 38 |
-
.theme-card.active { border-color: var(--gold); background: rgba(255,215,0,0.05); }
|
| 39 |
-
.theme-preview { height: 100px; background: #000; border-radius: 8px; margin-bottom: 12px; background-size: cover; background-position: center; }
|
| 40 |
-
|
| 41 |
-
#guild-selector { margin-bottom: 30px; }
|
| 42 |
-
.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; }
|
| 43 |
-
|
| 44 |
-
.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; }
|
| 45 |
-
</style>
|
| 46 |
-
</head>
|
| 47 |
-
<body>
|
| 48 |
-
<header>
|
| 49 |
-
<div style="display:flex; align-items:center; gap:16px">
|
| 50 |
-
<div style="font-size:32px">🎴</div>
|
| 51 |
-
<h1>Player Profiles</h1>
|
| 52 |
-
</div>
|
| 53 |
-
<div style="display:flex; gap:10px">
|
| 54 |
-
<a href="/premium" class="btn btn-secondary">Back to Premium</a>
|
| 55 |
-
<a href="/dashboard" class="btn btn-secondary">Dashboard</a>
|
| 56 |
-
</div>
|
| 57 |
-
</header>
|
| 58 |
-
|
| 59 |
-
<div class="container">
|
| 60 |
-
<div id="guild-selector">
|
| 61 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:10px">Select a Server to Configure</label>
|
| 62 |
-
<select id="server-list" class="server-select" onchange="loadConfig(this.value)">
|
| 63 |
-
<option value="">Loading your servers...</option>
|
| 64 |
-
</select>
|
| 65 |
-
</div>
|
| 66 |
-
|
| 67 |
-
<div class="card" id="config-card" style="display:none">
|
| 68 |
-
<h2>Profile Card Themes</h2>
|
| 69 |
-
<p>Choose the default theme for player profile cards generated in your server.</p>
|
| 70 |
-
|
| 71 |
-
<div class="theme-grid">
|
| 72 |
-
<div class="theme-card active" onclick="selectTheme('dark', this)">
|
| 73 |
-
<div class="theme-preview" style="background-image: linear-gradient(45deg, #0f0c29, #302b63, #24243e);"></div>
|
| 74 |
-
<div style="font-weight:700">Midnight (Default)</div>
|
| 75 |
-
</div>
|
| 76 |
-
<div class="theme-card" onclick="selectTheme('gold', this)">
|
| 77 |
-
<div class="theme-preview" style="background-image: linear-gradient(45deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);"></div>
|
| 78 |
-
<div style="font-weight:700">Royal Gold</div>
|
| 79 |
-
</div>
|
| 80 |
-
<div class="theme-card" onclick="selectTheme('neon', this)">
|
| 81 |
-
<div class="theme-preview" style="background-image: linear-gradient(45deg, #ec008c, #fc6767);"></div>
|
| 82 |
-
<div style="font-weight:700">Neon Pulse</div>
|
| 83 |
-
</div>
|
| 84 |
-
</div>
|
| 85 |
-
|
| 86 |
-
<div style="margin-top:32px">
|
| 87 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:12px">Server Custom Background URL (Optional)</label>
|
| 88 |
-
<input type="text" id="config-profile-bg" placeholder="https://..." style="width:100%; padding:14px; background:var(--surface2); border:1px solid var(--border); border-radius:10px; color:white; outline:none" oninput="checkChanges()">
|
| 89 |
-
</div>
|
| 90 |
-
</div>
|
| 91 |
-
</div>
|
| 92 |
-
|
| 93 |
-
<div class="save-bar" id="save-bar" style="display:none; max-width:800px; margin: 0 auto;">
|
| 94 |
-
<span style="font-size:14px; font-weight:500">You have unsaved changes!</span>
|
| 95 |
-
<button class="btn" onclick="saveConfig()">Save Profile Settings</button>
|
| 96 |
-
</div>
|
| 97 |
-
|
| 98 |
-
<script>
|
| 99 |
-
let currentGuildId = null;
|
| 100 |
-
let selectedTheme = 'dark';
|
| 101 |
-
|
| 102 |
-
async function init() {
|
| 103 |
-
try {
|
| 104 |
-
const serversR = await fetch('/api/servers');
|
| 105 |
-
const serversData = await serversR.json();
|
| 106 |
-
const serverSelect = document.getElementById('server-list');
|
| 107 |
-
const servers = serversData.servers || [];
|
| 108 |
-
|
| 109 |
-
if (servers.length === 0) {
|
| 110 |
-
serverSelect.innerHTML = '<option value="">No manageable servers found</option>';
|
| 111 |
-
return;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
serverSelect.innerHTML = '<option value="">-- Choose a Server --</option>' +
|
| 115 |
-
servers.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
|
| 116 |
-
} catch (e) { console.error(e); }
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
async function loadConfig(guildId) {
|
| 120 |
-
if (!guildId) {
|
| 121 |
-
document.getElementById('config-card').style.display = 'none';
|
| 122 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 123 |
-
return;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
currentGuildId = guildId;
|
| 127 |
-
document.getElementById('config-card').style.display = 'block';
|
| 128 |
-
|
| 129 |
-
try {
|
| 130 |
-
const r = await fetch(`/api/config/${guildId}`);
|
| 131 |
-
const data = await r.json();
|
| 132 |
-
document.getElementById('config-profile-bg').value = data.profileBg || '';
|
| 133 |
-
selectedTheme = data.profileTheme || 'dark';
|
| 134 |
-
updateThemeUI();
|
| 135 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 136 |
-
} catch (e) { alert('Failed to load configuration'); }
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
function selectTheme(theme, el) {
|
| 140 |
-
selectedTheme = theme;
|
| 141 |
-
updateThemeUI();
|
| 142 |
-
checkChanges();
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
function updateThemeUI() {
|
| 146 |
-
document.querySelectorAll('.theme-card').forEach(c => {
|
| 147 |
-
c.classList.remove('active');
|
| 148 |
-
if (c.textContent.toLowerCase().includes(selectedTheme)) c.classList.add('active');
|
| 149 |
-
});
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
function checkChanges() {
|
| 153 |
-
if (!currentGuildId) return;
|
| 154 |
-
document.getElementById('save-bar').style.display = 'flex';
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
async function saveConfig() {
|
| 158 |
-
const profileBg = document.getElementById('config-profile-bg').value;
|
| 159 |
-
const profileTheme = selectedTheme;
|
| 160 |
-
|
| 161 |
-
try {
|
| 162 |
-
const r = await fetch(`/api/config/${currentGuildId}`, {
|
| 163 |
-
method: 'POST',
|
| 164 |
-
headers: { 'Content-Type': 'application/json' },
|
| 165 |
-
body: JSON.stringify({ profileBg, profileTheme })
|
| 166 |
-
});
|
| 167 |
-
const data = await r.json();
|
| 168 |
-
if (data.success) {
|
| 169 |
-
alert('✅ Profile settings saved!');
|
| 170 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 171 |
-
} else {
|
| 172 |
-
alert('❌ Error: ' + data.error);
|
| 173 |
-
}
|
| 174 |
-
} catch (e) { alert('❌ Failed to save'); }
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
init();
|
| 178 |
-
</script>
|
| 179 |
-
</body>
|
| 180 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1 +1,11 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
py-cord[voice]
|
| 2 |
+
flask
|
| 3 |
+
requests
|
| 4 |
+
python-dotenv
|
| 5 |
+
tzlocal
|
| 6 |
+
Pillow
|
| 7 |
+
SpeechRecognition
|
| 8 |
+
pydub
|
| 9 |
+
aiodns
|
| 10 |
+
cchardet
|
| 11 |
+
gunicorn
|
roleStorage.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
|
| 4 |
-
console.log(">>> [MODULE] roleStorage.js: Initializing...");
|
| 5 |
-
|
| 6 |
-
const storage = require('./storage');
|
| 7 |
-
|
| 8 |
class RoleManager {
|
| 9 |
constructor() {
|
| 10 |
-
this.file = path.join(
|
| 11 |
this.roles = {};
|
| 12 |
this.load();
|
| 13 |
}
|
|
@@ -45,7 +41,6 @@ class RoleManager {
|
|
| 45 |
}
|
| 46 |
|
| 47 |
isWhitelisted(guildId, member) {
|
| 48 |
-
if (!member || !member.permissions) return false;
|
| 49 |
if (member.permissions.has('Administrator')) return true;
|
| 50 |
const allowedRoles = this.roles[guildId] || [];
|
| 51 |
return member.roles.cache.some(r => allowedRoles.includes(r.id));
|
|
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
class RoleManager {
|
| 5 |
constructor() {
|
| 6 |
+
this.file = path.join(__dirname, 'data', 'roles.json');
|
| 7 |
this.roles = {};
|
| 8 |
this.load();
|
| 9 |
}
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
isWhitelisted(guildId, member) {
|
|
|
|
| 44 |
if (member.permissions.has('Administrator')) return true;
|
| 45 |
const allowedRoles = this.roles[guildId] || [];
|
| 46 |
return member.roles.cache.some(r => allowedRoles.includes(r.id));
|
roster.html
DELETED
|
@@ -1,137 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>FriendlyBot — Roster List</title>
|
| 7 |
-
<link rel="icon" href="/logo.png" />
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #0a0a1a;
|
| 12 |
-
--surface: #12122a;
|
| 13 |
-
--border: rgba(255, 255, 255, 0.06);
|
| 14 |
-
--text: #fff;
|
| 15 |
-
--text-dim: rgba(255, 255, 255, 0.6);
|
| 16 |
-
--accent: #5865F2;
|
| 17 |
-
--radius: 16px;
|
| 18 |
-
}
|
| 19 |
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 20 |
-
body {
|
| 21 |
-
font-family: "Inter", sans-serif;
|
| 22 |
-
background: var(--bg);
|
| 23 |
-
color: var(--text);
|
| 24 |
-
min-height: 100vh;
|
| 25 |
-
padding: 40px 20px;
|
| 26 |
-
}
|
| 27 |
-
header {
|
| 28 |
-
max-width: 1000px;
|
| 29 |
-
margin: 0 auto 40px;
|
| 30 |
-
display: flex;
|
| 31 |
-
justify-content: space-between;
|
| 32 |
-
align-items: center;
|
| 33 |
-
}
|
| 34 |
-
h1 { font-size: 28px; font-weight: 700; }
|
| 35 |
-
.btn {
|
| 36 |
-
display: inline-block;
|
| 37 |
-
padding: 10px 20px;
|
| 38 |
-
background: var(--accent);
|
| 39 |
-
color: #fff;
|
| 40 |
-
text-decoration: none;
|
| 41 |
-
border-radius: 8px;
|
| 42 |
-
font-weight: 600;
|
| 43 |
-
font-size: 14px;
|
| 44 |
-
}
|
| 45 |
-
.container { max-width: 1000px; margin: 0 auto; }
|
| 46 |
-
.team-section {
|
| 47 |
-
background: var(--surface);
|
| 48 |
-
border: 1px solid var(--border);
|
| 49 |
-
border-radius: var(--radius);
|
| 50 |
-
padding: 24px;
|
| 51 |
-
margin-bottom: 24px;
|
| 52 |
-
}
|
| 53 |
-
.team-title {
|
| 54 |
-
font-size: 20px;
|
| 55 |
-
font-weight: 700;
|
| 56 |
-
margin-bottom: 16px;
|
| 57 |
-
color: var(--accent);
|
| 58 |
-
}
|
| 59 |
-
table { width: 100%; border-collapse: collapse; }
|
| 60 |
-
th, td {
|
| 61 |
-
text-align: left;
|
| 62 |
-
padding: 12px;
|
| 63 |
-
border-bottom: 1px solid var(--border);
|
| 64 |
-
}
|
| 65 |
-
th {
|
| 66 |
-
color: var(--text-dim);
|
| 67 |
-
font-size: 12px;
|
| 68 |
-
text-transform: uppercase;
|
| 69 |
-
letter-spacing: 1px;
|
| 70 |
-
}
|
| 71 |
-
tr:last-child td { border-bottom: none; }
|
| 72 |
-
.empty {
|
| 73 |
-
text-align: center;
|
| 74 |
-
color: var(--text-dim);
|
| 75 |
-
padding: 40px;
|
| 76 |
-
}
|
| 77 |
-
</style>
|
| 78 |
-
</head>
|
| 79 |
-
<body>
|
| 80 |
-
<header>
|
| 81 |
-
<h1>📋 Roster List</h1>
|
| 82 |
-
<a href="/" class="btn">Back to Dashboard</a>
|
| 83 |
-
</header>
|
| 84 |
-
|
| 85 |
-
<div class="container" id="app">
|
| 86 |
-
<div class="empty">Loading rosters...</div>
|
| 87 |
-
</div>
|
| 88 |
-
|
| 89 |
-
<script>
|
| 90 |
-
async function loadRosters() {
|
| 91 |
-
try {
|
| 92 |
-
const res = await fetch("/api/roster");
|
| 93 |
-
const data = await res.json();
|
| 94 |
-
const app = document.getElementById("app");
|
| 95 |
-
|
| 96 |
-
if (!data || Object.keys(data).length === 0) {
|
| 97 |
-
app.innerHTML = '<div class="empty">No rosters found. Use !roster-add @user Role in Discord to add one.</div>';
|
| 98 |
-
return;
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
let html = "";
|
| 102 |
-
Object.entries(data).forEach(([team, members]) => {
|
| 103 |
-
html += `<div class="team-section">
|
| 104 |
-
<div class="team-title">${team}</div>
|
| 105 |
-
<table>
|
| 106 |
-
<thead>
|
| 107 |
-
<tr><th>User</th><th>Role</th><th>Added</th></tr>
|
| 108 |
-
</thead>
|
| 109 |
-
<tbody>
|
| 110 |
-
${members.map(m => `
|
| 111 |
-
<tr>
|
| 112 |
-
<td>${escapeHtml(m.user)}</td>
|
| 113 |
-
<td>${escapeHtml(m.role)}</td>
|
| 114 |
-
<td>${escapeHtml(m.addedAt)}</td>
|
| 115 |
-
</tr>
|
| 116 |
-
`).join("")}
|
| 117 |
-
</tbody>
|
| 118 |
-
</table>
|
| 119 |
-
</div>`;
|
| 120 |
-
});
|
| 121 |
-
app.innerHTML = html;
|
| 122 |
-
} catch (err) {
|
| 123 |
-
document.getElementById("app").innerHTML = '<div class="empty">Failed to load rosters.</div>';
|
| 124 |
-
}
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function escapeHtml(str) {
|
| 128 |
-
if (!str) return "";
|
| 129 |
-
const d = document.createElement("div");
|
| 130 |
-
d.textContent = str;
|
| 131 |
-
return d.innerHTML;
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
loadRosters();
|
| 135 |
-
</script>
|
| 136 |
-
</body>
|
| 137 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scheduling.html
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>FriendlyBot — Match Scheduling</title>
|
| 7 |
-
<link rel="icon" href="/logo.png" />
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #0a0a1a; --surface: #12122a; --surface2: #1a1a3a; --border: rgba(255,255,255,0.08);
|
| 12 |
-
--text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
|
| 13 |
-
--accent: #5865F2; --radius: 16px; --red: #ED4245;
|
| 14 |
-
}
|
| 15 |
-
* { box-sizing: border-box; margin:0; padding:0; }
|
| 16 |
-
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
|
| 17 |
-
header { max-width: 800px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
|
| 18 |
-
h1 { font-size: 28px; font-weight: 700; }
|
| 19 |
-
.btn {
|
| 20 |
-
display: inline-block; padding: 10px 20px; background: var(--accent);
|
| 21 |
-
color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px; border: none; cursor: pointer;
|
| 22 |
-
}
|
| 23 |
-
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
|
| 24 |
-
.container { max-width: 800px; margin: 0 auto; }
|
| 25 |
-
.card {
|
| 26 |
-
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
|
| 27 |
-
border: 1px solid var(--border); border-radius: var(--radius);
|
| 28 |
-
padding: 32px; margin-bottom: 30px;
|
| 29 |
-
}
|
| 30 |
-
.card h2 { font-size: 20px; margin-bottom: 12px; }
|
| 31 |
-
.card p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
|
| 32 |
-
|
| 33 |
-
.config-grid { display: grid; gap: 24px; }
|
| 34 |
-
.input-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 35 |
-
input, select {
|
| 36 |
-
width: 100%; padding: 14px; background: var(--surface2); border: 1px solid var(--border);
|
| 37 |
-
border-radius: 10px; color: #fff; font-size: 15px; outline: none; transition: border 0.2s;
|
| 38 |
-
}
|
| 39 |
-
input:focus { border-color: var(--accent); }
|
| 40 |
-
|
| 41 |
-
.switch { position: relative; display: inline-block; width: 48px; height: 24px; }
|
| 42 |
-
.switch input { opacity: 0; width: 0; height: 0; }
|
| 43 |
-
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--surface2); transition: .4s; border-radius: 24px; border: 1px solid var(--border); }
|
| 44 |
-
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
|
| 45 |
-
input:checked + .slider { background-color: var(--gold); }
|
| 46 |
-
input:checked + .slider:before { transform: translateX(24px); }
|
| 47 |
-
|
| 48 |
-
#guild-selector { margin-bottom: 30px; }
|
| 49 |
-
.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; }
|
| 50 |
-
|
| 51 |
-
.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; }
|
| 52 |
-
</style>
|
| 53 |
-
</head>
|
| 54 |
-
<body>
|
| 55 |
-
<header>
|
| 56 |
-
<div style="display:flex; align-items:center; gap:16px">
|
| 57 |
-
<div style="font-size:32px">📅</div>
|
| 58 |
-
<h1>Match Scheduling</h1>
|
| 59 |
-
</div>
|
| 60 |
-
<div style="display:flex; gap:10px">
|
| 61 |
-
<a href="/premium" class="btn btn-secondary">Back to Premium</a>
|
| 62 |
-
<a href="/dashboard" class="btn btn-secondary">Dashboard</a>
|
| 63 |
-
</div>
|
| 64 |
-
</header>
|
| 65 |
-
|
| 66 |
-
<div class="container">
|
| 67 |
-
<div id="guild-selector">
|
| 68 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:10px">Select a Server to Configure</label>
|
| 69 |
-
<select id="server-list" class="server-select" onchange="loadConfig(this.value)">
|
| 70 |
-
<option value="">Loading your servers...</option>
|
| 71 |
-
</select>
|
| 72 |
-
</div>
|
| 73 |
-
|
| 74 |
-
<div class="card" id="config-card" style="display:none">
|
| 75 |
-
<h2>Premium Match Reminders</h2>
|
| 76 |
-
<p>Configure automated DM reminders for your league matches. Remind your players before the match starts.</p>
|
| 77 |
-
|
| 78 |
-
<div class="config-grid">
|
| 79 |
-
<div class="input-group">
|
| 80 |
-
<label>Enable DM Reminders</label>
|
| 81 |
-
<div style="display:flex; align-items:center; gap:12px">
|
| 82 |
-
<label class="switch">
|
| 83 |
-
<input type="checkbox" id="config-reminders-enabled" onchange="checkChanges()">
|
| 84 |
-
<span class="slider"></span>
|
| 85 |
-
</label>
|
| 86 |
-
<span style="font-size:14px; color:var(--text-dim)">Send DMs to players on the lineup board</span>
|
| 87 |
-
</div>
|
| 88 |
-
</div>
|
| 89 |
-
|
| 90 |
-
<div class="input-group">
|
| 91 |
-
<label>Lead Time (Minutes)</label>
|
| 92 |
-
<input type="number" id="config-reminders-lead" placeholder="30" min="5" max="1440" oninput="checkChanges()">
|
| 93 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">How many minutes before the match start time should the reminder be sent?</p>
|
| 94 |
-
</div>
|
| 95 |
-
</div>
|
| 96 |
-
</div>
|
| 97 |
-
</div>
|
| 98 |
-
|
| 99 |
-
<div class="save-bar" id="save-bar" style="display:none; max-width:800px; margin: 0 auto;">
|
| 100 |
-
<span style="font-size:14px; font-weight:500">You have unsaved changes!</span>
|
| 101 |
-
<button class="btn" onclick="saveConfig()">Save Scheduling Settings</button>
|
| 102 |
-
</div>
|
| 103 |
-
|
| 104 |
-
<script>
|
| 105 |
-
let currentGuildId = null;
|
| 106 |
-
|
| 107 |
-
async function init() {
|
| 108 |
-
try {
|
| 109 |
-
const serversR = await fetch('/api/servers');
|
| 110 |
-
const serversData = await serversR.json();
|
| 111 |
-
const serverSelect = document.getElementById('server-list');
|
| 112 |
-
const servers = serversData.servers || [];
|
| 113 |
-
|
| 114 |
-
if (servers.length === 0) {
|
| 115 |
-
serverSelect.innerHTML = '<option value="">No manageable servers found</option>';
|
| 116 |
-
return;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
serverSelect.innerHTML = '<option value="">-- Choose a Server --</option>' +
|
| 120 |
-
servers.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
|
| 121 |
-
} catch (e) { console.error(e); }
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
async function loadConfig(guildId) {
|
| 125 |
-
if (!guildId) {
|
| 126 |
-
document.getElementById('config-card').style.display = 'none';
|
| 127 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 128 |
-
return;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
currentGuildId = guildId;
|
| 132 |
-
document.getElementById('config-card').style.display = 'block';
|
| 133 |
-
|
| 134 |
-
try {
|
| 135 |
-
const r = await fetch(`/api/config/${guildId}`);
|
| 136 |
-
const data = await r.json();
|
| 137 |
-
document.getElementById('config-reminders-enabled').checked = !!data.remindersEnabled;
|
| 138 |
-
document.getElementById('config-reminders-lead').value = data.remindersLead || 30;
|
| 139 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 140 |
-
} catch (e) { alert('Failed to load configuration'); }
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
function checkChanges() {
|
| 144 |
-
if (!currentGuildId) return;
|
| 145 |
-
document.getElementById('save-bar').style.display = 'flex';
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
async function saveConfig() {
|
| 149 |
-
const remindersEnabled = document.getElementById('config-reminders-enabled').checked;
|
| 150 |
-
const remindersLead = parseInt(document.getElementById('config-reminders-lead').value) || 30;
|
| 151 |
-
|
| 152 |
-
try {
|
| 153 |
-
const r = await fetch(`/api/config/${currentGuildId}`, {
|
| 154 |
-
method: 'POST',
|
| 155 |
-
headers: { 'Content-Type': 'application/json' },
|
| 156 |
-
body: JSON.stringify({ remindersEnabled, remindersLead })
|
| 157 |
-
});
|
| 158 |
-
const data = await r.json();
|
| 159 |
-
if (data.success) {
|
| 160 |
-
alert('✅ Scheduling settings saved!');
|
| 161 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 162 |
-
} else {
|
| 163 |
-
alert('❌ Error: ' + data.error);
|
| 164 |
-
}
|
| 165 |
-
} catch (e) { alert('❌ Failed to save'); }
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
init();
|
| 169 |
-
</script>
|
| 170 |
-
</body>
|
| 171 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scrimRenderer.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* scrimRenderer.js - Scrimmage Mode Lineup Image Generator
|
| 3 |
-
* Displays two teams facing each other on a single pitch
|
| 4 |
-
*/
|
| 5 |
-
const { createCanvas, loadImage } = require('@napi-rs/canvas');
|
| 6 |
-
const { AttachmentBuilder } = require('discord.js');
|
| 7 |
-
const { renderLineupImage } = require('./lineupRenderer');
|
| 8 |
-
|
| 9 |
-
/**
|
| 10 |
-
* Render scrimmage lineup - two team images side by side
|
| 11 |
-
* Left: Team A (normal formation, attacking upward)
|
| 12 |
-
* Right: Team B (mirrored Y-axis - attacking downward, facing Team A)
|
| 13 |
-
*/
|
| 14 |
-
async function renderScrimmageImage(lineup, title, formation, client) {
|
| 15 |
-
const INDIVIDUAL_W = 1180;
|
| 16 |
-
const H = 620;
|
| 17 |
-
const W = INDIVIDUAL_W * 2 + 5; // Total width with gap
|
| 18 |
-
|
| 19 |
-
// Pre-fetch all user data
|
| 20 |
-
const allUserIds = new Set();
|
| 21 |
-
for (const players of lineup.values()) {
|
| 22 |
-
players.forEach(id => allUserIds.add(id));
|
| 23 |
-
}
|
| 24 |
-
const userDataMap = new Map();
|
| 25 |
-
if (client) {
|
| 26 |
-
await Promise.all(Array.from(allUserIds).map(async (uid) => {
|
| 27 |
-
try {
|
| 28 |
-
const user = await client.users.fetch(uid);
|
| 29 |
-
const avatarUrl = user.displayAvatarURL({ extension: 'png', size: 128 });
|
| 30 |
-
const imgBuf = await downloadImage(avatarUrl);
|
| 31 |
-
const img = await loadImage(imgBuf);
|
| 32 |
-
userDataMap.set(uid, { user, img });
|
| 33 |
-
} catch (e) {
|
| 34 |
-
userDataMap.set(uid, { user: null, img: null });
|
| 35 |
-
}
|
| 36 |
-
});
|
| 37 |
-
|
| 38 |
-
// --- Draw Team A on left half (normal orientation) ---
|
| 39 |
-
const canvas = createCanvas(W, H);
|
| 40 |
-
const ctx = canvas.getContext('2d');
|
| 41 |
-
const imgA = await loadImage(teamABuffer);
|
| 42 |
-
|
| 43 |
-
// Draw Team A on left half
|
| 44 |
-
ctx.drawImage(imgA, 0, 0, INDIVIDUAL_W, INDIVIDUAL_H);
|
| 45 |
-
|
| 46 |
-
// --- Draw Team B on right half (mirrored Y) ---
|
| 47 |
-
ctx.save();
|
| 48 |
-
ctx.translate(HALF_W, 0);
|
| 49 |
-
ctx.scale(-1, 1);
|
| 50 |
-
ctx.drawImage(imgB, -HALF_W, 0, INDIVIDUAL_W, INDIVIDUAL_H);
|
| 51 |
-
ctx.restore();
|
| 52 |
-
|
| 53 |
-
// --- Draw "VS" in the middle ---
|
| 54 |
-
ctx.fillStyle = '#ffffff';
|
| 55 |
-
ctx.font = 'bold 28px Arial, sans-serif';
|
| 56 |
-
ctx.textAlign = 'center';
|
| 57 |
-
ctx.fillText('VS', INDIVIDUAL_W + GAP / 2, H / 2);
|
| 58 |
-
|
| 59 |
-
// --- Footer ---
|
| 60 |
-
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
| 61 |
-
ctx.fillRect(0, H - 22, W, 22);
|
| 62 |
-
ctx.fillStyle = 'rgba(255,255,255,0.6)';
|
| 63 |
-
ctx.font = '10px Arial, sans-serif';
|
| 64 |
-
ctx.textAlign = 'center';
|
| 65 |
-
ctx.textBaseline = 'middle';
|
| 66 |
-
ctx.fillText('Generated by FriendlyBot', W / 2, H - 11);
|
| 67 |
-
|
| 68 |
-
return canvas.toBuffer('image/png');
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
async function createScrimmageAttachment(lineup, title, formation, client) {
|
| 72 |
-
const buffer = await renderScrimmageImage(lineup, title, formation, client);
|
| 73 |
-
return new AttachmentBuilder(buffer, { name: 'scrimmage.png' });
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
module.exports = { renderScrimmageImage, createScrimmageAttachment };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.js
CHANGED
|
@@ -2,13 +2,9 @@ const express = require('express');
|
|
| 2 |
const path = require('path');
|
| 3 |
const fs = require('fs');
|
| 4 |
const crypto = require('crypto');
|
| 5 |
-
const premiumStore = require('./premiumStore');
|
| 6 |
-
|
| 7 |
-
console.log(">>> [MODULE] server.js: Initializing...");
|
| 8 |
const app = express();
|
| 9 |
const port = process.env.PORT || 7860;
|
| 10 |
|
| 11 |
-
|
| 12 |
// Discord OAuth2 Config — reads from multiple possible env var names
|
| 13 |
const CLIENT_SECRET = process.env.CLIENT_SECRET || process.env.DISCORD_CLIENT_SECRET || '';
|
| 14 |
const REDIRECT_URI = process.env.REDIRECT_URI || process.env.DISCORD_REDIRECT_URL || '';
|
|
@@ -18,26 +14,17 @@ let discordClient = null;
|
|
| 18 |
let commandsDataRef = null;
|
| 19 |
|
| 20 |
// Session store (persisted to disk so logins survive restarts)
|
| 21 |
-
const
|
| 22 |
-
const SESSION_FILE = path.join(storage.PERSISTENT_DIR, 'sessions.json');
|
| 23 |
let sessions = new Map();
|
| 24 |
|
| 25 |
// Load sessions from disk on startup
|
| 26 |
try {
|
| 27 |
if (fs.existsSync(SESSION_FILE)) {
|
| 28 |
-
const
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
if (raw && typeof raw === 'object') {
|
| 32 |
-
sessions = new Map(Object.entries(raw));
|
| 33 |
-
console.log(`[*] Dashboard: Loaded ${sessions.size} persistent session(s).`);
|
| 34 |
-
}
|
| 35 |
-
}
|
| 36 |
}
|
| 37 |
-
} catch (e) {
|
| 38 |
-
console.error(`[*] Dashboard: Failed to load sessions: ${e.message}`);
|
| 39 |
-
}
|
| 40 |
-
console.log("[*] Dashboard: Session system initialized.");
|
| 41 |
|
| 42 |
function saveSessions() {
|
| 43 |
try {
|
|
@@ -52,25 +39,21 @@ function saveSessions() {
|
|
| 52 |
const logBuffer = [];
|
| 53 |
const MAX_LOGS = 200;
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
const
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
origErr.apply(console, args);
|
| 71 |
-
};
|
| 72 |
-
isHijacked = true;
|
| 73 |
-
}
|
| 74 |
|
| 75 |
app.use(express.json());
|
| 76 |
|
|
@@ -84,23 +67,10 @@ function hasDashboardPermissions(permissionBits) {
|
|
| 84 |
}
|
| 85 |
|
| 86 |
// --- Helper: Get redirect URI ---
|
| 87 |
-
function getRedirectUri(
|
| 88 |
-
// Prioritize building the URI dynamically from the incoming request.
|
| 89 |
-
// This allows duplicated/cloned Spaces to work perfectly out-of-the-box.
|
| 90 |
-
if (req) {
|
| 91 |
-
const host = req.get('host');
|
| 92 |
-
const protocol = req.protocol === 'http' && host.includes('.hf.space') ? 'https' : req.protocol;
|
| 93 |
-
const path = req.path === '/' ? '/' : '/callback';
|
| 94 |
-
return `${protocol}://${host}${path}`;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
if (REDIRECT_URI) return REDIRECT_URI;
|
| 98 |
-
|
| 99 |
const spaceId = process.env.SPACE_ID;
|
| 100 |
-
if (spaceId) {
|
| 101 |
-
const host = spaceId.includes('/') ? spaceId.replace('/', '-').toLowerCase() : spaceId.toLowerCase();
|
| 102 |
-
return `https://${host}.hf.space/callback`;
|
| 103 |
-
}
|
| 104 |
return `http://localhost:${port}/callback`;
|
| 105 |
}
|
| 106 |
|
|
@@ -124,10 +94,7 @@ function getSession(req) {
|
|
| 124 |
// --- Auth Middleware ---
|
| 125 |
function requireAuth(req, res, next) {
|
| 126 |
const session = getSession(req);
|
| 127 |
-
if (session && session.user)
|
| 128 |
-
req.user = session.user; // Attach user for convenience
|
| 129 |
-
return next();
|
| 130 |
-
}
|
| 131 |
res.status(401).json({ error: 'Unauthorized' });
|
| 132 |
}
|
| 133 |
|
|
@@ -139,15 +106,6 @@ app.use((req, res, next) => {
|
|
| 139 |
|
| 140 |
// --- Static Assets ---
|
| 141 |
app.get('/', (req, res) => {
|
| 142 |
-
// If we get an OAuth code on the root route, handle it using the root as the redirect_uri
|
| 143 |
-
if (req.query.code) {
|
| 144 |
-
console.log("[Dashboard] Received OAuth code on root route, handling...");
|
| 145 |
-
return handleOAuthCallback(req, res, getRedirectUri(req));
|
| 146 |
-
}
|
| 147 |
-
res.sendFile(path.join(__dirname, 'dashboard.html'));
|
| 148 |
-
});
|
| 149 |
-
|
| 150 |
-
app.get('/dashboard', (req, res) => {
|
| 151 |
res.sendFile(path.join(__dirname, 'dashboard.html'));
|
| 152 |
});
|
| 153 |
app.get('/logo.png', (req, res) => {
|
|
@@ -156,103 +114,26 @@ app.get('/logo.png', (req, res) => {
|
|
| 156 |
else res.status(404).send('Not found');
|
| 157 |
});
|
| 158 |
|
| 159 |
-
// Returns 200 as long as the web server is running.
|
| 160 |
-
// This prevents Hugging Face and other platforms from restarting the space
|
| 161 |
-
// while the Discord bot is still performing its initial connection handshake.
|
| 162 |
-
app.get('/healthz', (req, res) => {
|
| 163 |
-
const discordReady = !!(discordClient && discordClient.isReady && discordClient.isReady());
|
| 164 |
-
return res.status(200).json({
|
| 165 |
-
ok: true,
|
| 166 |
-
webReady: true,
|
| 167 |
-
discordReady: discordReady,
|
| 168 |
-
guilds: discordReady ? (discordClient.guilds?.cache?.size || 0) : 0
|
| 169 |
-
});
|
| 170 |
-
});
|
| 171 |
-
|
| 172 |
-
app.get('/tos', (req, res) => {
|
| 173 |
-
res.sendFile(path.join(__dirname, 'tos.html'));
|
| 174 |
-
});
|
| 175 |
-
|
| 176 |
-
app.get('/privacy', (req, res) => {
|
| 177 |
-
res.sendFile(path.join(__dirname, 'privacy.html'));
|
| 178 |
-
});
|
| 179 |
-
|
| 180 |
-
app.get('/league', (req, res) => {
|
| 181 |
-
res.sendFile(path.join(__dirname, 'league.html'));
|
| 182 |
-
});
|
| 183 |
-
|
| 184 |
-
app.get('/premium', (req, res) => {
|
| 185 |
-
res.sendFile(path.join(__dirname, 'premium.html'));
|
| 186 |
-
});
|
| 187 |
-
|
| 188 |
-
app.get('/aliases', (req, res) => {
|
| 189 |
-
res.sendFile(path.join(__dirname, 'aliases.html'));
|
| 190 |
-
});
|
| 191 |
-
|
| 192 |
-
app.get('/stats', (req, res) => {
|
| 193 |
-
res.sendFile(path.join(__dirname, 'stats.html'));
|
| 194 |
-
});
|
| 195 |
-
|
| 196 |
-
app.get('/scheduling', (req, res) => {
|
| 197 |
-
res.sendFile(path.join(__dirname, 'scheduling.html'));
|
| 198 |
-
});
|
| 199 |
-
|
| 200 |
-
app.get('/profiles', (req, res) => {
|
| 201 |
-
res.sendFile(path.join(__dirname, 'profiles.html'));
|
| 202 |
-
});
|
| 203 |
-
|
| 204 |
-
|
| 205 |
// --- Discord OAuth2: Step 1 — Redirect to Discord ---
|
| 206 |
app.get('/auth/login', (req, res) => {
|
| 207 |
const clientId = getClientId();
|
| 208 |
-
const redirect = encodeURIComponent(getRedirectUri(
|
| 209 |
-
console.log(`[Dashboard] Starting OAuth login. Redirect URI: ${getRedirectUri(req)}`);
|
| 210 |
const url = `https://discord.com/api/oauth2/authorize?client_id=${clientId}&redirect_uri=${redirect}&response_type=code&scope=identify%20guilds`;
|
| 211 |
res.redirect(url);
|
| 212 |
});
|
| 213 |
|
| 214 |
-
async function fetchWithRetry(url, options, retries =
|
| 215 |
-
|
| 216 |
-
'https://discord.com',
|
| 217 |
-
'https://canary.discord.com',
|
| 218 |
-
'https://ptb.discord.com'
|
| 219 |
-
];
|
| 220 |
-
|
| 221 |
-
for (let i = 0; i < endpoints.length; i++) {
|
| 222 |
-
const controller = new AbortController();
|
| 223 |
-
const timeoutId = setTimeout(() => controller.abort(), 20000); // 20s timeout
|
| 224 |
-
|
| 225 |
try {
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
// Only swap if it's a discord API call
|
| 230 |
-
if (url.includes('discord.com/api')) {
|
| 231 |
-
targetUrl = url.replace('https://discord.com', currentBase);
|
| 232 |
-
console.log(`[Dashboard] Connection Attempt ${i + 1} via ${new URL(currentBase).hostname}...`);
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
const res = await fetch(targetUrl, {
|
| 236 |
-
...options,
|
| 237 |
-
signal: controller.signal
|
| 238 |
-
});
|
| 239 |
-
clearTimeout(timeoutId);
|
| 240 |
-
|
| 241 |
-
if (!res.ok) {
|
| 242 |
-
const text = await res.text().catch(() => '');
|
| 243 |
-
console.warn(`[Dashboard] API returned ${res.status} from ${new URL(currentBase).hostname}`);
|
| 244 |
-
if (i === endpoints.length - 1) throw new Error(`HTTP ${res.status}: ${text}`);
|
| 245 |
-
continue; // Try next endpoint
|
| 246 |
-
}
|
| 247 |
return res;
|
| 248 |
} catch (err) {
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
// Short delay before next endpoint
|
| 256 |
await new Promise(r => setTimeout(r, 1000));
|
| 257 |
}
|
| 258 |
}
|
|
@@ -260,30 +141,11 @@ async function fetchWithRetry(url, options, retries = 3) {
|
|
| 260 |
|
| 261 |
// --- Discord OAuth2: Step 2 — Callback from Discord ---
|
| 262 |
// Support both /callback and /auth/callback to match any Discord redirect config
|
| 263 |
-
async function handleOAuthCallback(req, res
|
| 264 |
-
const { code
|
| 265 |
-
|
| 266 |
-
if (error) {
|
| 267 |
-
console.error(`[Dashboard] Discord returned error: ${error} (${error_description})`);
|
| 268 |
-
return res.redirect(`/?error=${error}`);
|
| 269 |
-
}
|
| 270 |
-
|
| 271 |
-
if (!code) {
|
| 272 |
-
console.warn(`[Dashboard] No code found in query parameters. URL: ${req.originalUrl}`);
|
| 273 |
-
return res.redirect('/?error=no_code');
|
| 274 |
-
}
|
| 275 |
-
|
| 276 |
-
// Ensure overrideRedirectUri is a string and not the 'next' function from Express
|
| 277 |
-
const usedRedirectUri = (typeof overrideRedirectUri === 'string') ? overrideRedirectUri : getRedirectUri(req);
|
| 278 |
-
console.log(`[Dashboard] Handling OAuth callback. Code: ${code.substring(0, 5)}... Redirect URI: ${usedRedirectUri}`);
|
| 279 |
-
|
| 280 |
-
if (!CLIENT_SECRET) {
|
| 281 |
-
console.error('[Dashboard] CRITICAL: CLIENT_SECRET is missing from environment variables.');
|
| 282 |
-
return res.redirect('/?error=server_error');
|
| 283 |
-
}
|
| 284 |
|
| 285 |
try {
|
| 286 |
-
console.log(`[Dashboard] Exchanging code for token... (Redirect URI: ${getRedirectUri()})`);
|
| 287 |
// Exchange code for token
|
| 288 |
const tokenRes = await fetchWithRetry('https://discord.com/api/oauth2/token', {
|
| 289 |
method: 'POST',
|
|
@@ -293,29 +155,21 @@ async function handleOAuthCallback(req, res, overrideRedirectUri) {
|
|
| 293 |
client_secret: CLIENT_SECRET,
|
| 294 |
grant_type: 'authorization_code',
|
| 295 |
code,
|
| 296 |
-
redirect_uri:
|
| 297 |
})
|
| 298 |
});
|
| 299 |
-
|
| 300 |
const tokenData = await tokenRes.json();
|
| 301 |
-
if (!tokenData.access_token)
|
| 302 |
-
console.error('[Dashboard] Token exchange failed:', tokenData);
|
| 303 |
-
return res.redirect('/?error=token_failed');
|
| 304 |
-
}
|
| 305 |
|
| 306 |
-
console.log(`[Dashboard] Token received. Fetching user profile...`);
|
| 307 |
// Fetch user profile
|
| 308 |
const userRes = await fetchWithRetry('https://discord.com/api/users/@me', {
|
| 309 |
headers: { Authorization: `Bearer ${tokenData.access_token}` }
|
| 310 |
});
|
| 311 |
const user = await userRes.json();
|
| 312 |
-
if (!user.id)
|
| 313 |
-
console.error('[Dashboard] Failed to fetch user profile:', user);
|
| 314 |
-
return res.redirect('/?error=user_failed');
|
| 315 |
-
}
|
| 316 |
|
| 317 |
// Fetch user guilds
|
| 318 |
-
console.log(`[Dashboard] Fetching guilds for user ${user.username}
|
| 319 |
const guildsRes = await fetchWithRetry('https://discord.com/api/users/@me/guilds', {
|
| 320 |
headers: { Authorization: `Bearer ${tokenData.access_token}` }
|
| 321 |
});
|
|
@@ -340,7 +194,6 @@ async function handleOAuthCallback(req, res, overrideRedirectUri) {
|
|
| 340 |
guilds: Array.isArray(userGuilds) ? userGuilds : [],
|
| 341 |
createdAt: Date.now()
|
| 342 |
});
|
| 343 |
-
saveSessions();
|
| 344 |
|
| 345 |
// Set cookie (7 days)
|
| 346 |
res.cookie('fb_session', sid, {
|
|
@@ -376,10 +229,7 @@ app.get('/auth/logout', (req, res) => {
|
|
| 376 |
return acc;
|
| 377 |
}, {});
|
| 378 |
const sid = cookies['fb_session'];
|
| 379 |
-
if (sid)
|
| 380 |
-
sessions.delete(sid);
|
| 381 |
-
saveSessions();
|
| 382 |
-
}
|
| 383 |
res.clearCookie('fb_session');
|
| 384 |
res.redirect('/');
|
| 385 |
});
|
|
@@ -405,14 +255,13 @@ app.get('/api/stats', requireAuth, (req, res) => {
|
|
| 405 |
servers: discordClient.guilds.cache.size,
|
| 406 |
members: totalMembers,
|
| 407 |
uptime: upStr,
|
| 408 |
-
commands:
|
| 409 |
inviteUrl
|
| 410 |
});
|
| 411 |
});
|
| 412 |
|
| 413 |
// --- Server List ---
|
| 414 |
// --- Server List (shared with bot + permissions) ---
|
| 415 |
-
let cachedOwnerId = null;
|
| 416 |
app.get('/api/servers', requireAuth, async (req, res) => {
|
| 417 |
try {
|
| 418 |
if (!discordClient || !discordClient.isReady()) {
|
|
@@ -420,39 +269,41 @@ app.get('/api/servers', requireAuth, async (req, res) => {
|
|
| 420 |
}
|
| 421 |
|
| 422 |
const userGuilds = req.dashSession.guilds || [];
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
cachedOwnerId = firstMember?.user?.id || firstMember?.id;
|
| 434 |
-
}
|
| 435 |
}
|
| 436 |
}
|
| 437 |
-
|
| 438 |
-
|
| 439 |
console.log(`[Dashboard] Request by ${req.dashSession.user.username} (Owner: ${isBotOwner})`);
|
| 440 |
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
|
| 457 |
const list = visibleGuilds.map(g => ({
|
| 458 |
name: g.name,
|
|
@@ -461,7 +312,7 @@ app.get('/api/servers', requireAuth, async (req, res) => {
|
|
| 461 |
icon: g.iconURL({ size: 64 }) || null
|
| 462 |
}));
|
| 463 |
|
| 464 |
-
if (isBotOwner) console.log(`[Dashboard] Owner access
|
| 465 |
console.log(`[Dashboard] Serving ${list.length} managed servers to ${req.dashSession.user.username}`);
|
| 466 |
res.json({ pending: false, servers: list });
|
| 467 |
} catch (err) {
|
|
@@ -481,24 +332,14 @@ app.get('/api/config/:guildId', requireAuth, (req, res) => {
|
|
| 481 |
if (!hasPerms) return res.status(403).json({ error: 'Missing permissions' });
|
| 482 |
|
| 483 |
const storage = require('./storage');
|
| 484 |
-
const roleStorage = require('./roleStorage');
|
| 485 |
const config = storage.data.config[guildId] || {};
|
| 486 |
res.json({
|
| 487 |
prefix: storage.getPrefix(guildId),
|
| 488 |
autoFriendlyEnabled: config.autoFriendlyEnabled || false,
|
| 489 |
autoFriendlyInterval: config.autoFriendlyInterval || 40,
|
| 490 |
autoFriendlyChannel: config.autoFriendlyChannel || null,
|
| 491 |
-
postEnabled:
|
| 492 |
-
postChannelId: config.postChannelId || null
|
| 493 |
-
friendlyText: config.friendlyText || "⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: {needed}\n@everyone",
|
| 494 |
-
cleanupHours: config.cleanupHours || 2,
|
| 495 |
-
lineupCleanupHours: config.lineupCleanupHours || 2,
|
| 496 |
-
remindersEnabled: !!config.remindersEnabled,
|
| 497 |
-
remindersLead: config.remindersLead || 30,
|
| 498 |
-
aliases: config.aliases || {},
|
| 499 |
-
leaderboardChannel: config.leaderboardChannel || null,
|
| 500 |
-
statsFrequency: config.statsFrequency || 'never',
|
| 501 |
-
whitelistedRoles: roleStorage.roles[guildId] || []
|
| 502 |
});
|
| 503 |
});
|
| 504 |
|
|
@@ -514,28 +355,9 @@ app.get('/api/channels/:guildId', requireAuth, (req, res) => {
|
|
| 514 |
res.json(channels);
|
| 515 |
});
|
| 516 |
|
| 517 |
-
app.get('/api/roles/:guildId', requireAuth, (req, res) => {
|
| 518 |
-
const { guildId } = req.params;
|
| 519 |
-
const userGuilds = req.dashSession.guilds || [];
|
| 520 |
-
const ug = userGuilds.find(g => g.id === guildId);
|
| 521 |
-
|
| 522 |
-
if (!ug) return res.status(403).json({ error: 'Access denied' });
|
| 523 |
-
const hasPerms = (BigInt(ug.permissions) & BigInt(0x20)) || (BigInt(ug.permissions) & BigInt(0x8));
|
| 524 |
-
if (!hasPerms) return res.status(403).json({ error: 'Missing permissions' });
|
| 525 |
-
|
| 526 |
-
if (!discordClient || !discordClient.isReady()) return res.json([]);
|
| 527 |
-
const guild = discordClient.guilds.cache.get(guildId);
|
| 528 |
-
if (!guild) return res.json([]);
|
| 529 |
-
|
| 530 |
-
const roles = guild.roles.cache
|
| 531 |
-
.filter(r => r.name !== '@everyone')
|
| 532 |
-
.map(r => ({ id: r.id, name: r.name, color: r.hexColor }));
|
| 533 |
-
res.json(roles);
|
| 534 |
-
});
|
| 535 |
-
|
| 536 |
app.post('/api/config/:guildId', requireAuth, (req, res) => {
|
| 537 |
const { guildId } = req.params;
|
| 538 |
-
const { prefix, autoFriendlyEnabled, autoFriendlyInterval, autoFriendlyChannel, postEnabled, postChannelId
|
| 539 |
const userGuilds = req.dashSession.guilds || [];
|
| 540 |
const ug = userGuilds.find(g => g.id === guildId);
|
| 541 |
|
|
@@ -557,31 +379,6 @@ app.post('/api/config/:guildId', requireAuth, (req, res) => {
|
|
| 557 |
if (autoFriendlyChannel !== undefined) storage.data.config[guildId].autoFriendlyChannel = autoFriendlyChannel;
|
| 558 |
if (postEnabled !== undefined) storage.data.config[guildId].postEnabled = !!postEnabled;
|
| 559 |
if (postChannelId !== undefined) storage.data.config[guildId].postChannelId = postChannelId;
|
| 560 |
-
if (friendlyText !== undefined) storage.data.config[guildId].friendlyText = friendlyText;
|
| 561 |
-
if (cleanupHours !== undefined) storage.data.config[guildId].cleanupHours = parseInt(cleanupHours) || 2;
|
| 562 |
-
if (lineupCleanupHours !== undefined) storage.data.config[guildId].lineupCleanupHours = parseInt(lineupCleanupHours) || 2;
|
| 563 |
-
if (remindersEnabled !== undefined) storage.data.config[guildId].remindersEnabled = !!remindersEnabled;
|
| 564 |
-
if (remindersLead !== undefined) storage.data.config[guildId].remindersLead = parseInt(remindersLead) || 30;
|
| 565 |
-
if (aliases !== undefined) storage.data.config[guildId].aliases = aliases;
|
| 566 |
-
if (leaderboardChannel !== undefined) {
|
| 567 |
-
if (storage.data.config[guildId].leaderboardChannel !== leaderboardChannel) {
|
| 568 |
-
storage.data.config[guildId].lastLeaderboard = 0;
|
| 569 |
-
storage.data.config[guildId].leaderboardMessageId = null;
|
| 570 |
-
}
|
| 571 |
-
storage.data.config[guildId].leaderboardChannel = leaderboardChannel;
|
| 572 |
-
}
|
| 573 |
-
if (statsFrequency !== undefined) {
|
| 574 |
-
if (storage.data.config[guildId].statsFrequency !== statsFrequency) {
|
| 575 |
-
storage.data.config[guildId].lastLeaderboard = 0;
|
| 576 |
-
}
|
| 577 |
-
storage.data.config[guildId].statsFrequency = statsFrequency;
|
| 578 |
-
}
|
| 579 |
-
|
| 580 |
-
if (whitelistedRoles !== undefined) {
|
| 581 |
-
const roleStorage = require('./roleStorage');
|
| 582 |
-
roleStorage.roles[guildId] = Array.isArray(whitelistedRoles) ? whitelistedRoles : [];
|
| 583 |
-
roleStorage.save();
|
| 584 |
-
}
|
| 585 |
|
| 586 |
storage.save('config');
|
| 587 |
res.json({ success: true, message: 'Settings updated successfully' });
|
|
@@ -589,67 +386,18 @@ app.post('/api/config/:guildId', requireAuth, (req, res) => {
|
|
| 589 |
|
| 590 |
// --- Command List ---
|
| 591 |
app.get('/api/commands', requireAuth, (req, res) => {
|
| 592 |
-
|
| 593 |
-
{ name: 'friendly', description: 'Start a match poll for players to join', staff: true },
|
| 594 |
-
{ name: 'lineup', description: 'Generate the interactive lineup board', staff: true },
|
| 595 |
-
{ name: 'scrimlineup', description: 'Generate a scrimmage lineup board with two teams facing each other', staff: true },
|
| 596 |
-
{ name: 'lineupimage', description: 'Generate a high-quality visual lineup image', staff: true },
|
| 597 |
-
{ name: 'leaguematch', description: 'Schedule a league match with an opponent', staff: true },
|
| 598 |
-
{ name: 'win', description: 'Record a match victory', staff: true },
|
| 599 |
-
{ name: 'loss', description: 'Record a match defeat', staff: true },
|
| 600 |
-
{ name: 'draw', description: 'Record a match draw', staff: true },
|
| 601 |
-
{ name: 'managerlineup', description: 'Open the advanced GUI lineup editor', staff: true },
|
| 602 |
-
{ name: 'tactic', description: 'Show tactical analysis for a formation', staff: true },
|
| 603 |
-
{ name: 'teamrandom', description: 'Randomize players into balanced teams', staff: true },
|
| 604 |
-
{ name: 'swap', description: 'Swap two players on the lineup board', staff: true },
|
| 605 |
-
{ name: 'sendlink', description: 'Send a quick match or lobby link', staff: true },
|
| 606 |
-
|
| 607 |
-
{ name: 'setup', description: 'Open the bot settings configuration panel', admin: true },
|
| 608 |
-
{ name: 'clear', description: 'Bulk delete messages from the channel', admin: true },
|
| 609 |
-
{ name: 'lock', description: 'Lock the channel to prevent messaging', admin: true },
|
| 610 |
-
{ name: 'unlock', description: 'Unlock the channel for messaging', admin: true },
|
| 611 |
-
{ name: 'addrole', description: 'Add a role to the bot staff whitelist', admin: true },
|
| 612 |
-
{ name: 'removerole', description: 'Remove a role from the whitelist', admin: true },
|
| 613 |
-
{ name: 'sync', description: 'Synchronize all slash commands', admin: true },
|
| 614 |
-
|
| 615 |
-
{ name: 'ping', description: 'Check the bot response latency' },
|
| 616 |
-
{ name: 'help', description: 'View the full list of available commands' },
|
| 617 |
-
{ name: 'record', description: 'View the server global match record' },
|
| 618 |
-
{ name: 'profile', description: 'View your player profile stats' },
|
| 619 |
-
{ name: 'profileimage', description: 'Generate a visual player profile card' },
|
| 620 |
-
{ name: 'playerstats', description: 'View detailed stats for a player' },
|
| 621 |
-
{ name: 'top', description: 'Show the leaderboard of top players' },
|
| 622 |
-
{ name: 'matchpredict', description: 'Get an AI prediction for the current lineup' },
|
| 623 |
-
{ name: 'friendlybotsettings', description: 'View bot status and permissions' }
|
| 624 |
-
];
|
| 625 |
-
|
| 626 |
-
res.json(fullCommands);
|
| 627 |
-
});
|
| 628 |
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
const allPremium = premiumStore.getAllPremiumUsers();
|
| 632 |
-
const list = await Promise.all(Object.entries(allPremium).map(async ([userId, record]) => {
|
| 633 |
-
let userTag = userId;
|
| 634 |
-
let avatarUrl = '';
|
| 635 |
-
try {
|
| 636 |
-
if (discordClient) {
|
| 637 |
-
const user = await discordClient.users.fetch(userId).catch(() => null);
|
| 638 |
-
if (user) {
|
| 639 |
-
userTag = user.tag;
|
| 640 |
-
avatarUrl = user.displayAvatarURL({ size: 32, dynamic: true });
|
| 641 |
-
}
|
| 642 |
-
}
|
| 643 |
-
} catch (e) {}
|
| 644 |
-
return { userId, userTag, avatarUrl, grantedAt: record.grantedAt, reason: record.reason };
|
| 645 |
-
}));
|
| 646 |
-
res.json({ list });
|
| 647 |
-
});
|
| 648 |
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
|
|
|
|
|
|
|
|
|
| 653 |
});
|
| 654 |
|
| 655 |
// --- Invite URL ---
|
|
@@ -692,49 +440,13 @@ app.post('/api/action/:name', requireAuth, async (req, res) => {
|
|
| 692 |
|
| 693 |
// --- Start ---
|
| 694 |
function startServer(client, cmdsData) {
|
| 695 |
-
console.log("[*] Dashboard: startServer() called. Initializing express...");
|
| 696 |
-
const net = require('net');
|
| 697 |
-
const checkServer = net.createServer();
|
| 698 |
-
|
| 699 |
-
checkServer.on('listening', () => {
|
| 700 |
-
checkServer.close(() => {
|
| 701 |
-
console.log(`[*] Port ${port} is available, starting server...`);
|
| 702 |
-
startServerInternal(client, cmdsData);
|
| 703 |
-
});
|
| 704 |
-
});
|
| 705 |
-
|
| 706 |
-
checkServer.on('error', (err) => {
|
| 707 |
-
if (err.code === 'EADDRINUSE') {
|
| 708 |
-
console.error(`[!] ERROR: Port ${port} is already in use. Another bot instance is running.`);
|
| 709 |
-
console.error(`[!] Please close other instances before starting this one.`);
|
| 710 |
-
process.exit(1);
|
| 711 |
-
} else {
|
| 712 |
-
console.error(`[!] Server error: ${err.message}`);
|
| 713 |
-
process.exit(1);
|
| 714 |
-
}
|
| 715 |
-
});
|
| 716 |
-
|
| 717 |
-
checkServer.listen(port, '0.0.0.0');
|
| 718 |
-
}
|
| 719 |
-
|
| 720 |
-
function startServerInternal(client, cmdsData) {
|
| 721 |
-
hijackConsole();
|
| 722 |
discordClient = client || null;
|
| 723 |
commandsDataRef = cmdsData || null;
|
| 724 |
|
| 725 |
app.listen(port, '0.0.0.0', () => {
|
| 726 |
-
const finalRedirect = getRedirectUri();
|
| 727 |
-
console.log(`[*] --------------------------------------------------`);
|
| 728 |
console.log(`[*] Web Server running on port ${port}`);
|
| 729 |
-
console.log(`[*]
|
| 730 |
-
console.log(`[*] DASHBOARD URL: ${finalRedirect.replace('/callback', '').replace('/auth/callback', '')}`);
|
| 731 |
-
console.log(`[*] REDIRECT URI: ${finalRedirect}`);
|
| 732 |
-
console.log(`[*] --------------------------------------------------`);
|
| 733 |
-
console.log(`[*] IMPORTANT: Ensure the REDIRECT URI above is added exactly to your`);
|
| 734 |
-
console.log(`[*] Discord Developer Portal -> OAuth2 -> Redirects section.`);
|
| 735 |
-
console.log(`[*] --------------------------------------------------`);
|
| 736 |
});
|
| 737 |
}
|
| 738 |
|
| 739 |
-
|
| 740 |
module.exports = { startServer, app };
|
|
|
|
| 2 |
const path = require('path');
|
| 3 |
const fs = require('fs');
|
| 4 |
const crypto = require('crypto');
|
|
|
|
|
|
|
|
|
|
| 5 |
const app = express();
|
| 6 |
const port = process.env.PORT || 7860;
|
| 7 |
|
|
|
|
| 8 |
// Discord OAuth2 Config — reads from multiple possible env var names
|
| 9 |
const CLIENT_SECRET = process.env.CLIENT_SECRET || process.env.DISCORD_CLIENT_SECRET || '';
|
| 10 |
const REDIRECT_URI = process.env.REDIRECT_URI || process.env.DISCORD_REDIRECT_URL || '';
|
|
|
|
| 14 |
let commandsDataRef = null;
|
| 15 |
|
| 16 |
// Session store (persisted to disk so logins survive restarts)
|
| 17 |
+
const SESSION_FILE = path.join(__dirname, 'data', 'sessions.json');
|
|
|
|
| 18 |
let sessions = new Map();
|
| 19 |
|
| 20 |
// Load sessions from disk on startup
|
| 21 |
try {
|
| 22 |
if (fs.existsSync(SESSION_FILE)) {
|
| 23 |
+
const raw = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf8'));
|
| 24 |
+
sessions = new Map(Object.entries(raw));
|
| 25 |
+
console.log(`[*] Dashboard: Loaded ${sessions.size} persistent session(s).`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
+
} catch (e) {}
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
function saveSessions() {
|
| 30 |
try {
|
|
|
|
| 39 |
const logBuffer = [];
|
| 40 |
const MAX_LOGS = 200;
|
| 41 |
|
| 42 |
+
// Hijack console.log & console.error to capture logs
|
| 43 |
+
const origLog = console.log;
|
| 44 |
+
const origErr = console.error;
|
| 45 |
+
console.log = (...args) => {
|
| 46 |
+
const line = args.map(a => typeof a === 'string' ? a : JSON.stringify(a)).join(' ');
|
| 47 |
+
logBuffer.push(line);
|
| 48 |
+
if (logBuffer.length > MAX_LOGS) logBuffer.shift();
|
| 49 |
+
origLog.apply(console, args);
|
| 50 |
+
};
|
| 51 |
+
console.error = (...args) => {
|
| 52 |
+
const line = '[Error] ' + args.map(a => typeof a === 'string' ? a : JSON.stringify(a)).join(' ');
|
| 53 |
+
logBuffer.push(line);
|
| 54 |
+
if (logBuffer.length > MAX_LOGS) logBuffer.shift();
|
| 55 |
+
origErr.apply(console, args);
|
| 56 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
app.use(express.json());
|
| 59 |
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
// --- Helper: Get redirect URI ---
|
| 70 |
+
function getRedirectUri() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
if (REDIRECT_URI) return REDIRECT_URI;
|
|
|
|
| 72 |
const spaceId = process.env.SPACE_ID;
|
| 73 |
+
if (spaceId) return `https://${spaceId.replace('/', '-').toLowerCase()}.hf.space/callback`;
|
|
|
|
|
|
|
|
|
|
| 74 |
return `http://localhost:${port}/callback`;
|
| 75 |
}
|
| 76 |
|
|
|
|
| 94 |
// --- Auth Middleware ---
|
| 95 |
function requireAuth(req, res, next) {
|
| 96 |
const session = getSession(req);
|
| 97 |
+
if (session && session.user) return next();
|
|
|
|
|
|
|
|
|
|
| 98 |
res.status(401).json({ error: 'Unauthorized' });
|
| 99 |
}
|
| 100 |
|
|
|
|
| 106 |
|
| 107 |
// --- Static Assets ---
|
| 108 |
app.get('/', (req, res) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
res.sendFile(path.join(__dirname, 'dashboard.html'));
|
| 110 |
});
|
| 111 |
app.get('/logo.png', (req, res) => {
|
|
|
|
| 114 |
else res.status(404).send('Not found');
|
| 115 |
});
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
// --- Discord OAuth2: Step 1 — Redirect to Discord ---
|
| 118 |
app.get('/auth/login', (req, res) => {
|
| 119 |
const clientId = getClientId();
|
| 120 |
+
const redirect = encodeURIComponent(getRedirectUri());
|
|
|
|
| 121 |
const url = `https://discord.com/api/oauth2/authorize?client_id=${clientId}&redirect_uri=${redirect}&response_type=code&scope=identify%20guilds`;
|
| 122 |
res.redirect(url);
|
| 123 |
});
|
| 124 |
|
| 125 |
+
async function fetchWithRetry(url, options, retries = 2) {
|
| 126 |
+
for (let i = 0; i <= retries; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
try {
|
| 128 |
+
const res = await fetch(url, options);
|
| 129 |
+
if (!res.ok && i < retries) throw new Error(`HTTP ${res.status}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
return res;
|
| 131 |
} catch (err) {
|
| 132 |
+
if (i === retries) throw err;
|
| 133 |
+
console.warn(`[Dashboard] Connection failed, rotating endpoint and retrying... (${i + 1}/${retries})`);
|
| 134 |
+
try {
|
| 135 |
+
require('./network_fix').rotateEndpoint();
|
| 136 |
+
} catch (e) {}
|
|
|
|
|
|
|
| 137 |
await new Promise(r => setTimeout(r, 1000));
|
| 138 |
}
|
| 139 |
}
|
|
|
|
| 141 |
|
| 142 |
// --- Discord OAuth2: Step 2 — Callback from Discord ---
|
| 143 |
// Support both /callback and /auth/callback to match any Discord redirect config
|
| 144 |
+
async function handleOAuthCallback(req, res) {
|
| 145 |
+
const { code } = req.query;
|
| 146 |
+
if (!code) return res.redirect('/?error=no_code');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
try {
|
|
|
|
| 149 |
// Exchange code for token
|
| 150 |
const tokenRes = await fetchWithRetry('https://discord.com/api/oauth2/token', {
|
| 151 |
method: 'POST',
|
|
|
|
| 155 |
client_secret: CLIENT_SECRET,
|
| 156 |
grant_type: 'authorization_code',
|
| 157 |
code,
|
| 158 |
+
redirect_uri: getRedirectUri()
|
| 159 |
})
|
| 160 |
});
|
|
|
|
| 161 |
const tokenData = await tokenRes.json();
|
| 162 |
+
if (!tokenData.access_token) return res.redirect('/?error=token_failed');
|
|
|
|
|
|
|
|
|
|
| 163 |
|
|
|
|
| 164 |
// Fetch user profile
|
| 165 |
const userRes = await fetchWithRetry('https://discord.com/api/users/@me', {
|
| 166 |
headers: { Authorization: `Bearer ${tokenData.access_token}` }
|
| 167 |
});
|
| 168 |
const user = await userRes.json();
|
| 169 |
+
if (!user.id) return res.redirect('/?error=user_failed');
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
// Fetch user guilds
|
| 172 |
+
console.log(`[Dashboard] Fetching guilds for user ${user.username}...`);
|
| 173 |
const guildsRes = await fetchWithRetry('https://discord.com/api/users/@me/guilds', {
|
| 174 |
headers: { Authorization: `Bearer ${tokenData.access_token}` }
|
| 175 |
});
|
|
|
|
| 194 |
guilds: Array.isArray(userGuilds) ? userGuilds : [],
|
| 195 |
createdAt: Date.now()
|
| 196 |
});
|
|
|
|
| 197 |
|
| 198 |
// Set cookie (7 days)
|
| 199 |
res.cookie('fb_session', sid, {
|
|
|
|
| 229 |
return acc;
|
| 230 |
}, {});
|
| 231 |
const sid = cookies['fb_session'];
|
| 232 |
+
if (sid) sessions.delete(sid);
|
|
|
|
|
|
|
|
|
|
| 233 |
res.clearCookie('fb_session');
|
| 234 |
res.redirect('/');
|
| 235 |
});
|
|
|
|
| 255 |
servers: discordClient.guilds.cache.size,
|
| 256 |
members: totalMembers,
|
| 257 |
uptime: upStr,
|
| 258 |
+
commands: commandsDataRef ? commandsDataRef.length : 0,
|
| 259 |
inviteUrl
|
| 260 |
});
|
| 261 |
});
|
| 262 |
|
| 263 |
// --- Server List ---
|
| 264 |
// --- Server List (shared with bot + permissions) ---
|
|
|
|
| 265 |
app.get('/api/servers', requireAuth, async (req, res) => {
|
| 266 |
try {
|
| 267 |
if (!discordClient || !discordClient.isReady()) {
|
|
|
|
| 269 |
}
|
| 270 |
|
| 271 |
const userGuilds = req.dashSession.guilds || [];
|
| 272 |
+
const app = await discordClient.application.fetch().catch(() => null);
|
| 273 |
+
|
| 274 |
+
// Owner recognition for both single-owner apps and team-owned apps.
|
| 275 |
+
const ownerCandidates = new Set();
|
| 276 |
+
if (app?.owner?.id) ownerCandidates.add(app.owner.id);
|
| 277 |
+
if (app?.owner?.ownerId) ownerCandidates.add(app.owner.ownerId);
|
| 278 |
+
if (app?.owner?.members) {
|
| 279 |
+
for (const member of app.owner.members.values()) {
|
| 280 |
+
if (member?.id) ownerCandidates.add(member.id);
|
| 281 |
+
if (member?.user?.id) ownerCandidates.add(member.user.id);
|
|
|
|
|
|
|
| 282 |
}
|
| 283 |
}
|
| 284 |
+
const isBotOwner = ownerCandidates.has(req.dashSession.user.id);
|
| 285 |
+
|
| 286 |
console.log(`[Dashboard] Request by ${req.dashSession.user.username} (Owner: ${isBotOwner})`);
|
| 287 |
|
| 288 |
+
let visibleGuilds = [];
|
| 289 |
+
if (isBotOwner) {
|
| 290 |
+
visibleGuilds = Array.from(discordClient.guilds.cache.values());
|
| 291 |
+
} else {
|
| 292 |
+
const mutualGuilds = userGuilds
|
| 293 |
+
.filter(ug => discordClient.guilds.cache.has(ug.id))
|
| 294 |
+
.filter(Boolean);
|
| 295 |
+
|
| 296 |
+
const manageableGuilds = mutualGuilds.filter(ug => {
|
| 297 |
+
const permBits = ug.permissions ?? ug.permissions_new;
|
| 298 |
+
return hasDashboardPermissions(permBits);
|
| 299 |
+
});
|
| 300 |
+
|
| 301 |
+
// Fallback: if Discord doesn't return permission bits reliably, still show shared guilds.
|
| 302 |
+
const guildsToShow = manageableGuilds.length > 0 ? manageableGuilds : mutualGuilds;
|
| 303 |
+
visibleGuilds = guildsToShow
|
| 304 |
+
.map(ug => discordClient.guilds.cache.get(ug.id))
|
| 305 |
+
.filter(Boolean);
|
| 306 |
+
}
|
| 307 |
|
| 308 |
const list = visibleGuilds.map(g => ({
|
| 309 |
name: g.name,
|
|
|
|
| 312 |
icon: g.iconURL({ size: 64 }) || null
|
| 313 |
}));
|
| 314 |
|
| 315 |
+
if (isBotOwner) console.log(`[Dashboard] Owner access enabled for ${req.dashSession.user.username}`);
|
| 316 |
console.log(`[Dashboard] Serving ${list.length} managed servers to ${req.dashSession.user.username}`);
|
| 317 |
res.json({ pending: false, servers: list });
|
| 318 |
} catch (err) {
|
|
|
|
| 332 |
if (!hasPerms) return res.status(403).json({ error: 'Missing permissions' });
|
| 333 |
|
| 334 |
const storage = require('./storage');
|
|
|
|
| 335 |
const config = storage.data.config[guildId] || {};
|
| 336 |
res.json({
|
| 337 |
prefix: storage.getPrefix(guildId),
|
| 338 |
autoFriendlyEnabled: config.autoFriendlyEnabled || false,
|
| 339 |
autoFriendlyInterval: config.autoFriendlyInterval || 40,
|
| 340 |
autoFriendlyChannel: config.autoFriendlyChannel || null,
|
| 341 |
+
postEnabled: config.postEnabled !== false, // Default to true
|
| 342 |
+
postChannelId: config.postChannelId || null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
});
|
| 344 |
});
|
| 345 |
|
|
|
|
| 355 |
res.json(channels);
|
| 356 |
});
|
| 357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
app.post('/api/config/:guildId', requireAuth, (req, res) => {
|
| 359 |
const { guildId } = req.params;
|
| 360 |
+
const { prefix, autoFriendlyEnabled, autoFriendlyInterval, autoFriendlyChannel, postEnabled, postChannelId } = req.body;
|
| 361 |
const userGuilds = req.dashSession.guilds || [];
|
| 362 |
const ug = userGuilds.find(g => g.id === guildId);
|
| 363 |
|
|
|
|
| 379 |
if (autoFriendlyChannel !== undefined) storage.data.config[guildId].autoFriendlyChannel = autoFriendlyChannel;
|
| 380 |
if (postEnabled !== undefined) storage.data.config[guildId].postEnabled = !!postEnabled;
|
| 381 |
if (postChannelId !== undefined) storage.data.config[guildId].postChannelId = postChannelId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
|
| 383 |
storage.save('config');
|
| 384 |
res.json({ success: true, message: 'Settings updated successfully' });
|
|
|
|
| 386 |
|
| 387 |
// --- Command List ---
|
| 388 |
app.get('/api/commands', requireAuth, (req, res) => {
|
| 389 |
+
if (!commandsDataRef) return res.json([]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
+
const adminCmds = ['setup', 'post', 'clear', 'lock', 'unlock', 'giverole', 'addrole', 'removerole'];
|
| 392 |
+
const staffCmds = ['win', 'loss', 'draw', 'lineup', 'managerlineup', 'leaguematch', 'lineupimage'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
+
const list = commandsDataRef.map(c => ({
|
| 395 |
+
name: c.name,
|
| 396 |
+
description: c.description,
|
| 397 |
+
admin: adminCmds.includes(c.name),
|
| 398 |
+
staff: staffCmds.includes(c.name)
|
| 399 |
+
}));
|
| 400 |
+
res.json(list);
|
| 401 |
});
|
| 402 |
|
| 403 |
// --- Invite URL ---
|
|
|
|
| 440 |
|
| 441 |
// --- Start ---
|
| 442 |
function startServer(client, cmdsData) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
discordClient = client || null;
|
| 444 |
commandsDataRef = cmdsData || null;
|
| 445 |
|
| 446 |
app.listen(port, '0.0.0.0', () => {
|
|
|
|
|
|
|
| 447 |
console.log(`[*] Web Server running on port ${port}`);
|
| 448 |
+
console.log(`[*] Dashboard: ${getRedirectUri().replace('/auth/callback', '')}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
});
|
| 450 |
}
|
| 451 |
|
|
|
|
| 452 |
module.exports = { startServer, app };
|
stats.html
DELETED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>FriendlyBot — Advanced Stats</title>
|
| 7 |
-
<link rel="icon" href="/logo.png" />
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #0a0a1a; --surface: #12122a; --surface2: #1a1a3a; --border: rgba(255,255,255,0.08);
|
| 12 |
-
--text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
|
| 13 |
-
--accent: #5865F2; --radius: 16px; --red: #ED4245;
|
| 14 |
-
}
|
| 15 |
-
* { box-sizing: border-box; margin:0; padding:0; }
|
| 16 |
-
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
|
| 17 |
-
header { max-width: 800px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
|
| 18 |
-
h1 { font-size: 28px; font-weight: 700; }
|
| 19 |
-
.btn {
|
| 20 |
-
display: inline-block; padding: 10px 20px; background: var(--accent);
|
| 21 |
-
color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px; border: none; cursor: pointer;
|
| 22 |
-
}
|
| 23 |
-
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
|
| 24 |
-
.container { max-width: 800px; margin: 0 auto; }
|
| 25 |
-
.card {
|
| 26 |
-
background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
|
| 27 |
-
border: 1px solid var(--border); border-radius: var(--radius);
|
| 28 |
-
padding: 32px; margin-bottom: 30px;
|
| 29 |
-
}
|
| 30 |
-
.card h2 { font-size: 20px; margin-bottom: 12px; }
|
| 31 |
-
.card p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
|
| 32 |
-
|
| 33 |
-
.config-grid { display: grid; gap: 24px; }
|
| 34 |
-
.input-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 35 |
-
input, select {
|
| 36 |
-
width: 100%; padding: 14px; background: var(--surface2); border: 1px solid var(--border);
|
| 37 |
-
border-radius: 10px; color: #fff; font-size: 15px; outline: none;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
#guild-selector { margin-bottom: 30px; }
|
| 41 |
-
.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; }
|
| 42 |
-
|
| 43 |
-
.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; }
|
| 44 |
-
</style>
|
| 45 |
-
</head>
|
| 46 |
-
<body>
|
| 47 |
-
<header>
|
| 48 |
-
<div style="display:flex; align-items:center; gap:16px">
|
| 49 |
-
<div style="font-size:32px">📊</div>
|
| 50 |
-
<h1>Advanced Stats</h1>
|
| 51 |
-
</div>
|
| 52 |
-
<div style="display:flex; gap:10px">
|
| 53 |
-
<a href="/premium" class="btn btn-secondary">Back to Premium</a>
|
| 54 |
-
<a href="/dashboard" class="btn btn-secondary">Dashboard</a>
|
| 55 |
-
</div>
|
| 56 |
-
</header>
|
| 57 |
-
|
| 58 |
-
<div class="container">
|
| 59 |
-
<div id="guild-selector">
|
| 60 |
-
<label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:10px">Select a Server to Configure</label>
|
| 61 |
-
<select id="server-list" class="server-select" onchange="loadConfig(this.value)">
|
| 62 |
-
<option value="">Loading your servers...</option>
|
| 63 |
-
</select>
|
| 64 |
-
</div>
|
| 65 |
-
|
| 66 |
-
<div class="card" id="config-card" style="display:none">
|
| 67 |
-
<h2>Leaderboards & Analytics</h2>
|
| 68 |
-
<p>Configure how stats are tracked and displayed in your server.</p>
|
| 69 |
-
|
| 70 |
-
<div class="config-grid">
|
| 71 |
-
<div class="input-group">
|
| 72 |
-
<label>Leaderboard Channel</label>
|
| 73 |
-
<select id="config-leaderboard-channel" onchange="checkChanges()">
|
| 74 |
-
<option value="">Select a channel...</option>
|
| 75 |
-
</select>
|
| 76 |
-
<p style="font-size:12px; color:var(--text-dim); margin-top:8px">The bot will automatically update a leaderboard message in this channel.</p>
|
| 77 |
-
</div>
|
| 78 |
-
|
| 79 |
-
<div class="input-group">
|
| 80 |
-
<label>Auto-Post Stats</label>
|
| 81 |
-
<select id="config-stats-frequency" onchange="checkChanges()">
|
| 82 |
-
<option value="never">Never</option>
|
| 83 |
-
<option value="daily">Daily</option>
|
| 84 |
-
<option value="weekly">Weekly</option>
|
| 85 |
-
<option value="monthly">Monthly</option>
|
| 86 |
-
</select>
|
| 87 |
-
<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>
|
| 88 |
-
</div>
|
| 89 |
-
</div>
|
| 90 |
-
</div>
|
| 91 |
-
</div>
|
| 92 |
-
|
| 93 |
-
<div class="save-bar" id="save-bar" style="display:none; max-width:800px; margin: 0 auto;">
|
| 94 |
-
<span style="font-size:14px; font-weight:500">You have unsaved changes!</span>
|
| 95 |
-
<button class="btn" onclick="saveConfig()">Save Stats Settings</button>
|
| 96 |
-
</div>
|
| 97 |
-
|
| 98 |
-
<script>
|
| 99 |
-
let currentGuildId = null;
|
| 100 |
-
|
| 101 |
-
async function init() {
|
| 102 |
-
try {
|
| 103 |
-
const serversR = await fetch('/api/servers');
|
| 104 |
-
const serversData = await serversR.json();
|
| 105 |
-
const serverSelect = document.getElementById('server-list');
|
| 106 |
-
const servers = serversData.servers || [];
|
| 107 |
-
|
| 108 |
-
if (servers.length === 0) {
|
| 109 |
-
serverSelect.innerHTML = '<option value="">No manageable servers found</option>';
|
| 110 |
-
return;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
serverSelect.innerHTML = '<option value="">-- Choose a Server --</option>' +
|
| 114 |
-
servers.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
|
| 115 |
-
} catch (e) { console.error(e); }
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
async function loadConfig(guildId) {
|
| 119 |
-
if (!guildId) {
|
| 120 |
-
document.getElementById('config-card').style.display = 'none';
|
| 121 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 122 |
-
return;
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
currentGuildId = guildId;
|
| 126 |
-
document.getElementById('config-card').style.display = 'block';
|
| 127 |
-
|
| 128 |
-
try {
|
| 129 |
-
const [configR, channelsR] = await Promise.all([
|
| 130 |
-
fetch(`/api/config/${guildId}`),
|
| 131 |
-
fetch(`/api/channels/${guildId}`)
|
| 132 |
-
]);
|
| 133 |
-
|
| 134 |
-
const data = await configR.json();
|
| 135 |
-
const channels = await channelsR.json();
|
| 136 |
-
|
| 137 |
-
const channelSelect = document.getElementById('config-leaderboard-channel');
|
| 138 |
-
channelSelect.innerHTML = '<option value="">Select a channel...</option>' +
|
| 139 |
-
channels.map(c => `<option value="${c.id}" ${c.id === data.leaderboardChannel ? 'selected' : ''}>#${c.name}</option>`).join('');
|
| 140 |
-
|
| 141 |
-
document.getElementById('config-stats-frequency').value = data.statsFrequency || 'never';
|
| 142 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 143 |
-
} catch (e) { alert('Failed to load configuration'); }
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
function checkChanges() {
|
| 147 |
-
if (!currentGuildId) return;
|
| 148 |
-
document.getElementById('save-bar').style.display = 'flex';
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
async function saveConfig() {
|
| 152 |
-
const leaderboardChannel = document.getElementById('config-leaderboard-channel').value;
|
| 153 |
-
const statsFrequency = document.getElementById('config-stats-frequency').value;
|
| 154 |
-
|
| 155 |
-
try {
|
| 156 |
-
const r = await fetch(`/api/config/${currentGuildId}`, {
|
| 157 |
-
method: 'POST',
|
| 158 |
-
headers: { 'Content-Type': 'application/json' },
|
| 159 |
-
body: JSON.stringify({ leaderboardChannel, statsFrequency })
|
| 160 |
-
});
|
| 161 |
-
const data = await r.json();
|
| 162 |
-
if (data.success) {
|
| 163 |
-
alert('✅ Stats settings saved!');
|
| 164 |
-
document.getElementById('save-bar').style.display = 'none';
|
| 165 |
-
} else {
|
| 166 |
-
alert('❌ Error: ' + data.error);
|
| 167 |
-
}
|
| 168 |
-
} catch (e) { alert('❌ Failed to save'); }
|
| 169 |
-
}
|
| 170 |
-
|
| 171 |
-
init();
|
| 172 |
-
</script>
|
| 173 |
-
</body>
|
| 174 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
storage.js
CHANGED
|
@@ -1,151 +1,83 @@
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
// --- File Paths ---
|
| 7 |
-
// --- Persistence Configuration (Hugging Face Buckets) ---
|
| 8 |
-
// The bucket should be mounted at /home/node/app/data (as seen in Space settings)
|
| 9 |
-
const PERSISTENT_DIR = path.isAbsolute(process.env.DATA_PATH || "")
|
| 10 |
-
? process.env.DATA_PATH
|
| 11 |
-
: path.join(__dirname, 'data');
|
| 12 |
-
|
| 13 |
-
console.log(`[STORAGE] Using persistent directory: ${PERSISTENT_DIR}`);
|
| 14 |
-
|
| 15 |
-
if (!fs.existsSync(PERSISTENT_DIR)) {
|
| 16 |
-
console.log(`[STORAGE] Creating persistent directory...`);
|
| 17 |
-
fs.mkdirSync(PERSISTENT_DIR, { recursive: true });
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
const GUILD_SETTINGS_FILE = path.join(PERSISTENT_DIR, "guild_settings.json");
|
| 21 |
-
const CONFIG_FILE = path.join(PERSISTENT_DIR, "lineup_access.json");
|
| 22 |
-
const PLAYER_STATS_FILE = path.join(PERSISTENT_DIR, "player_stats.json");
|
| 23 |
-
const STATE_FILE = path.join(PERSISTENT_DIR, "state.json");
|
| 24 |
-
const BROADCAST_FILE = path.join(PERSISTENT_DIR, "broadcast_history.json");
|
| 25 |
-
|
| 26 |
-
function loadJson(path, defaultValue = {}) {
|
| 27 |
-
if (fs.existsSync(path)) {
|
| 28 |
-
try {
|
| 29 |
-
const data = fs.readFileSync(path, 'utf8');
|
| 30 |
-
return JSON.parse(data);
|
| 31 |
-
} catch (e) {
|
| 32 |
-
console.warn(`[STORAGE] Failed to load ${path}:`, e.message);
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
return defaultValue;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
function saveJson(path, data) {
|
| 39 |
-
try {
|
| 40 |
-
fs.writeFileSync(path, JSON.stringify(data, null, 2));
|
| 41 |
-
} catch (e) {
|
| 42 |
-
console.error(`[STORAGE] Failed to save ${path}:`, e.message);
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
class StorageManager {
|
| 47 |
constructor() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
this.data = {
|
| 49 |
-
|
| 50 |
-
roles: {},
|
| 51 |
-
stats: {},
|
| 52 |
-
active_polls: {},
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
broadcasts: [], // Broadcast history
|
| 56 |
-
scheduled_matches: [], // Scheduled league matches
|
| 57 |
-
cleanup_queue: [], // Messages to be deleted
|
| 58 |
-
onboarded: {}, // GuildId -> Set of UserIds who got the welcome DM
|
| 59 |
-
dmall_sessions: {}, // SessionId -> Session Data
|
| 60 |
-
muted_users: {} // UserId -> true (users who mute friendly DMs)
|
| 61 |
};
|
|
|
|
| 62 |
this.loadAll();
|
| 63 |
}
|
| 64 |
|
| 65 |
loadAll() {
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
const stats = loadJson(PLAYER_STATS_FILE, {});
|
| 78 |
-
this.data.stats = stats;
|
| 79 |
-
|
| 80 |
-
// Load State
|
| 81 |
-
const state = loadJson(STATE_FILE, {});
|
| 82 |
-
this.data.active_polls = state.polls || {};
|
| 83 |
-
this.data.processed_messages = new Set(state.processed || []);
|
| 84 |
-
this.data.settings = state.settings || {};
|
| 85 |
-
|
| 86 |
-
// Load Broadcasts
|
| 87 |
-
this.data.broadcasts = loadJson(BROADCAST_FILE, []);
|
| 88 |
|
| 89 |
-
|
| 90 |
-
this.
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
|
|
|
| 97 |
}
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
break;
|
| 104 |
-
case 'roles':
|
| 105 |
-
saveJson(CONFIG_FILE, Object.fromEntries(
|
| 106 |
-
Object.entries(this.data.roles).map(([k, v]) => [k, Array.from(v)])
|
| 107 |
-
));
|
| 108 |
-
break;
|
| 109 |
-
case 'stats':
|
| 110 |
-
saveJson(PLAYER_STATS_FILE, this.data.stats);
|
| 111 |
-
break;
|
| 112 |
-
case 'active_polls':
|
| 113 |
-
this.saveState();
|
| 114 |
-
break;
|
| 115 |
-
case 'settings':
|
| 116 |
-
this.saveState();
|
| 117 |
-
break;
|
| 118 |
-
case 'broadcasts':
|
| 119 |
-
saveJson(BROADCAST_FILE, this.data.broadcasts);
|
| 120 |
-
break;
|
| 121 |
-
default:
|
| 122 |
-
console.warn(`[STORAGE] Unknown save type: ${type}`);
|
| 123 |
}
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
dmall_sessions: this.data.dmall_sessions,
|
| 135 |
-
muted_users: this.data.muted_users
|
| 136 |
-
});
|
| 137 |
}
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
this.
|
| 142 |
-
|
| 143 |
-
this.save('broadcasts');
|
| 144 |
-
this.saveState();
|
| 145 |
}
|
| 146 |
|
| 147 |
getPrefix(guildId) {
|
| 148 |
-
|
|
|
|
| 149 |
}
|
| 150 |
|
| 151 |
setPrefix(guildId, prefix) {
|
|
@@ -153,34 +85,7 @@ class StorageManager {
|
|
| 153 |
this.data.config[guildId].prefix = prefix;
|
| 154 |
this.save('config');
|
| 155 |
}
|
| 156 |
-
|
| 157 |
-
getRecord(guildId) {
|
| 158 |
-
if (!this.data.config[guildId]) this.data.config[guildId] = {};
|
| 159 |
-
if (!this.data.config[guildId].record) {
|
| 160 |
-
this.data.config[guildId].record = { wins: 0, losses: 0, draws: 0 };
|
| 161 |
-
}
|
| 162 |
-
return this.data.config[guildId].record;
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
addStat(userId, statType, amount = 1) {
|
| 166 |
-
if (!this.data.stats[userId]) {
|
| 167 |
-
this.data.stats[userId] = {
|
| 168 |
-
matches: 0,
|
| 169 |
-
wins: 0,
|
| 170 |
-
losses: 0,
|
| 171 |
-
draws: 0,
|
| 172 |
-
goals: 0,
|
| 173 |
-
assists: 0,
|
| 174 |
-
mvps: 0
|
| 175 |
-
};
|
| 176 |
-
}
|
| 177 |
-
this.data.stats[userId][statType] = (this.data.stats[userId][statType] || 0) + amount;
|
| 178 |
-
this.save('stats');
|
| 179 |
-
}
|
| 180 |
}
|
| 181 |
|
| 182 |
-
const storage = new
|
| 183 |
-
|
| 184 |
-
storage.PERSISTENT_DIR = PERSISTENT_DIR;
|
| 185 |
-
console.log(">>> [MODULE] storage.js: Fully initialized.");
|
| 186 |
-
module.exports = storage;
|
|
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
|
| 4 |
+
class Storage {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
constructor() {
|
| 6 |
+
this.dir = path.join(__dirname, 'data');
|
| 7 |
+
if (!fs.existsSync(this.dir)) fs.mkdirSync(this.dir);
|
| 8 |
+
|
| 9 |
+
this.files = {
|
| 10 |
+
settings: path.join(this.dir, 'settings.json'),
|
| 11 |
+
roles: path.join(this.dir, 'roles.json'),
|
| 12 |
+
stats: path.join(this.dir, 'stats.json'),
|
| 13 |
+
active_polls: path.join(this.dir, 'active_polls.json'),
|
| 14 |
+
records: path.join(this.dir, 'records.json'),
|
| 15 |
+
config: path.join(this.dir, 'config.json')
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
this.data = {
|
| 19 |
+
settings: {},
|
| 20 |
+
roles: {},
|
| 21 |
+
stats: {},
|
| 22 |
+
active_polls: {},
|
| 23 |
+
records: {},
|
| 24 |
+
config: {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
};
|
| 26 |
+
|
| 27 |
this.loadAll();
|
| 28 |
}
|
| 29 |
|
| 30 |
loadAll() {
|
| 31 |
+
for (const [key, file] of Object.entries(this.files)) {
|
| 32 |
+
if (fs.existsSync(file)) {
|
| 33 |
+
try {
|
| 34 |
+
this.data[key] = JSON.parse(fs.readFileSync(file, 'utf8'));
|
| 35 |
+
} catch (e) {
|
| 36 |
+
console.error(`Error loading ${key}: ${e}`);
|
| 37 |
+
this.data[key] = {};
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
save(key) {
|
| 44 |
+
if (this.files[key]) {
|
| 45 |
+
const output = this.data[key] || {};
|
| 46 |
+
fs.writeFileSync(this.files[key], JSON.stringify(output, null, 2));
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
|
| 50 |
+
saveAll() {
|
| 51 |
+
for (const key of Object.keys(this.data)) this.save(key);
|
| 52 |
}
|
| 53 |
|
| 54 |
+
// --- Helper Methods ---
|
| 55 |
+
getRecord(guildId) {
|
| 56 |
+
if (!this.data.records[guildId]) {
|
| 57 |
+
this.data.records[guildId] = { wins: 0, losses: 0, draws: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
+
return this.data.records[guildId];
|
| 60 |
}
|
| 61 |
|
| 62 |
+
addStat(userId, type) {
|
| 63 |
+
if (!this.data.stats[userId]) {
|
| 64 |
+
this.data.stats[userId] = { matches: 0, goals: 0, mvps: 0 };
|
| 65 |
+
}
|
| 66 |
+
if (this.data.stats[userId][type] !== undefined) {
|
| 67 |
+
this.data.stats[userId][type]++;
|
| 68 |
+
this.save('stats');
|
| 69 |
+
}
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
+
isWhitelisted(guildId, member) {
|
| 73 |
+
if (member.permissions.has('Administrator')) return true;
|
| 74 |
+
const allowedRoles = this.data.roles[guildId] || [];
|
| 75 |
+
return member.roles.cache.some(r => allowedRoles.includes(r.id));
|
|
|
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
getPrefix(guildId) {
|
| 79 |
+
if (!guildId) return "!";
|
| 80 |
+
return this.data.config[guildId]?.prefix || "!";
|
| 81 |
}
|
| 82 |
|
| 83 |
setPrefix(guildId, prefix) {
|
|
|
|
| 85 |
this.data.config[guildId].prefix = prefix;
|
| 86 |
this.save('config');
|
| 87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
+
const storage = new Storage();
|
| 91 |
+
module.exports = storage;
|
|
|
|
|
|
|
|
|
style.css
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
* {
|
| 2 |
+
margin: 0;
|
| 3 |
+
padding: 0;
|
| 4 |
+
box-sizing: border-box;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
body {
|
| 8 |
+
font-family: 'Inter', sans-serif;
|
| 9 |
+
background-color: #0f1014;
|
| 10 |
+
color: #ffffff;
|
| 11 |
+
height: 100vh;
|
| 12 |
+
display: flex;
|
| 13 |
+
overflow: hidden;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/* Sidebar */
|
| 17 |
+
.sidebar {
|
| 18 |
+
width: 260px;
|
| 19 |
+
background-color: #1a1b21;
|
| 20 |
+
border-right: 1px solid #2a2b32;
|
| 21 |
+
display: flex;
|
| 22 |
+
flex-direction: column;
|
| 23 |
+
padding: 20px;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.sidebar-header {
|
| 27 |
+
display: flex;
|
| 28 |
+
align-items: center;
|
| 29 |
+
padding: 10px;
|
| 30 |
+
margin-bottom: 20px;
|
| 31 |
+
background: #5865f2;
|
| 32 |
+
border-radius: 8px;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.logo {
|
| 36 |
+
width: 32px;
|
| 37 |
+
height: 32px;
|
| 38 |
+
border-radius: 50%;
|
| 39 |
+
margin-right: 10px;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.sidebar-header h1 {
|
| 43 |
+
font-size: 1.1rem;
|
| 44 |
+
font-weight: 700;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.back-btn {
|
| 48 |
+
background: #2a2b32;
|
| 49 |
+
color: #b9bbbe;
|
| 50 |
+
padding: 10px;
|
| 51 |
+
border-radius: 6px;
|
| 52 |
+
text-decoration: none;
|
| 53 |
+
font-size: 0.85rem;
|
| 54 |
+
text-align: center;
|
| 55 |
+
margin-bottom: 20px;
|
| 56 |
+
display: block;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.nav-menu {
|
| 60 |
+
flex-grow: 1;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.nav-item {
|
| 64 |
+
display: flex;
|
| 65 |
+
align-items: center;
|
| 66 |
+
padding: 12px;
|
| 67 |
+
color: #b9bbbe;
|
| 68 |
+
text-decoration: none;
|
| 69 |
+
border-radius: 6px;
|
| 70 |
+
margin-bottom: 5px;
|
| 71 |
+
font-size: 0.9rem;
|
| 72 |
+
transition: all 0.2s;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.nav-item:hover, .nav-item.active {
|
| 76 |
+
background-color: #2a2b32;
|
| 77 |
+
color: white;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.nav-item i {
|
| 81 |
+
width: 20px;
|
| 82 |
+
margin-right: 12px;
|
| 83 |
+
font-size: 1rem;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.sidebar-footer {
|
| 87 |
+
border-top: 1px solid #2a2b32;
|
| 88 |
+
padding-top: 20px;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/* Main Content */
|
| 92 |
+
.main-content {
|
| 93 |
+
flex-grow: 1;
|
| 94 |
+
padding: 40px;
|
| 95 |
+
overflow-y: auto;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
header {
|
| 99 |
+
margin-bottom: 30px;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
header h2 {
|
| 103 |
+
font-size: 1.8rem;
|
| 104 |
+
font-weight: 800;
|
| 105 |
+
margin-bottom: 10px;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
header p {
|
| 109 |
+
color: #72767d;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.card {
|
| 113 |
+
background-color: #1a1b21;
|
| 114 |
+
border: 1px solid #2a2b32;
|
| 115 |
+
border-radius: 12px;
|
| 116 |
+
padding: 30px;
|
| 117 |
+
max-width: 800px;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.card h3 {
|
| 121 |
+
font-size: 1.2rem;
|
| 122 |
+
margin-bottom: 25px;
|
| 123 |
+
color: #5865f2;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.input-group {
|
| 127 |
+
margin-bottom: 20px;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
label {
|
| 131 |
+
display: block;
|
| 132 |
+
margin-bottom: 8px;
|
| 133 |
+
font-size: 0.85rem;
|
| 134 |
+
font-weight: 600;
|
| 135 |
+
color: #b9bbbe;
|
| 136 |
+
text-transform: uppercase;
|
| 137 |
+
letter-spacing: 0.5px;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
textarea {
|
| 141 |
+
width: 100%;
|
| 142 |
+
background-color: #0f1014;
|
| 143 |
+
border: 1px solid #2a2b32;
|
| 144 |
+
border-radius: 8px;
|
| 145 |
+
color: white;
|
| 146 |
+
padding: 15px;
|
| 147 |
+
font-family: 'Fira Code', monospace;
|
| 148 |
+
font-size: 0.9rem;
|
| 149 |
+
resize: vertical;
|
| 150 |
+
min-height: 100px;
|
| 151 |
+
outline: none;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
textarea:focus {
|
| 155 |
+
border-color: #5865f2;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.hint {
|
| 159 |
+
font-size: 0.8rem;
|
| 160 |
+
color: #5d5f66;
|
| 161 |
+
margin-top: 8px;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.btn-primary {
|
| 165 |
+
background-color: #5865f2;
|
| 166 |
+
color: white;
|
| 167 |
+
border: none;
|
| 168 |
+
padding: 12px 25px;
|
| 169 |
+
border-radius: 6px;
|
| 170 |
+
font-weight: 700;
|
| 171 |
+
cursor: pointer;
|
| 172 |
+
transition: opacity 0.2s;
|
| 173 |
+
display: block;
|
| 174 |
+
margin-left: auto;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
/* Server Selection Grid */
|
| 178 |
+
.server-grid {
|
| 179 |
+
display: grid;
|
| 180 |
+
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
| 181 |
+
gap: 20px;
|
| 182 |
+
margin-bottom: 40px;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.server-card {
|
| 186 |
+
background-color: #1a1b21;
|
| 187 |
+
border: 1px solid #2a2b32;
|
| 188 |
+
border-radius: 12px;
|
| 189 |
+
padding: 20px;
|
| 190 |
+
display: flex;
|
| 191 |
+
align-items: center;
|
| 192 |
+
text-decoration: none;
|
| 193 |
+
color: white;
|
| 194 |
+
transition: transform 0.2s, background-color 0.2s;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.server-card:hover {
|
| 198 |
+
background-color: #2a2b32;
|
| 199 |
+
transform: translateY(-2px);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.server-icon, .server-icon-placeholder {
|
| 203 |
+
width: 64px;
|
| 204 |
+
height: 64px;
|
| 205 |
+
border-radius: 12px;
|
| 206 |
+
margin-right: 15px;
|
| 207 |
+
background-color: #2f3136;
|
| 208 |
+
display: flex;
|
| 209 |
+
align-items: center;
|
| 210 |
+
justify-content: center;
|
| 211 |
+
font-size: 1.5rem;
|
| 212 |
+
font-weight: 700;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.add-server {
|
| 216 |
+
border: 1px dashed #5865f2;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.add-icon {
|
| 220 |
+
width: 64px;
|
| 221 |
+
height: 64px;
|
| 222 |
+
border-radius: 12px;
|
| 223 |
+
background-color: #2f3136;
|
| 224 |
+
color: #5865f2;
|
| 225 |
+
display: flex;
|
| 226 |
+
align-items: center;
|
| 227 |
+
justify-content: center;
|
| 228 |
+
font-size: 2.5rem;
|
| 229 |
+
font-weight: 300;
|
| 230 |
+
margin-right: 15px;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.server-name {
|
| 234 |
+
font-weight: 700;
|
| 235 |
+
font-size: 1rem;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.btn-primary:hover {
|
| 239 |
+
opacity: 0.9;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.btn-primary:disabled {
|
| 243 |
+
opacity: 0.5;
|
| 244 |
+
cursor: not-allowed;
|
| 245 |
+
}
|
tacticRenderer.js
DELETED
|
@@ -1,324 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* tacticRenderer.js - Tactic Board Image Generator
|
| 3 |
-
* Renders tactical formations with numbered positions and player info
|
| 4 |
-
*/
|
| 5 |
-
const { createCanvas, loadImage } = require('@napi-rs/canvas');
|
| 6 |
-
const { AttachmentBuilder } = require('discord.js');
|
| 7 |
-
const https = require('https');
|
| 8 |
-
const http = require('http');
|
| 9 |
-
|
| 10 |
-
// Tactic data for each 7v7 formation
|
| 11 |
-
const TACTICS = {
|
| 12 |
-
"default": {
|
| 13 |
-
name: "4-2-1 Formation",
|
| 14 |
-
summary: "Balanced formation with strong wing play and solid defense",
|
| 15 |
-
attack: "• Wingers stay wide to stretch defense\n• CM pushes forward to support striker\n• Fullbacks provide width in attack",
|
| 16 |
-
defense: "• Four defenders maintain compact shape\n• CM drops deep to protect back line\n• Press high when opportunity arises",
|
| 17 |
-
keyPoints: ["• Use width with RW/LW", "• CM timed runs into box", "• Fullbacks stay disciplined"]
|
| 18 |
-
},
|
| 19 |
-
"3-1-2": {
|
| 20 |
-
name: "3-1-2 Formation",
|
| 21 |
-
summary: "Compact midfield with dual strikers creating goal threats",
|
| 22 |
-
attack: "• Wingers cut inside to create overloads\n• CM acts as primary playmaker\n• Two strikers rotate positions constantly",
|
| 23 |
-
defense: "• Three CBs provide excellent cover\n• CM shields the back three\n• Force opponents wide",
|
| 24 |
-
keyPoints: ["• CBs play tight triangle", "• CM controls tempo", "• Strikers interchange positions"]
|
| 25 |
-
},
|
| 26 |
-
"3-0-3": {
|
| 27 |
-
name: "3-0-3 Formation",
|
| 28 |
-
summary: "Attacking formation with three forwards and no defensive mid",
|
| 29 |
-
attack: "• Three forwards press high constantly\n• Quick transitions through wings\n• Overload opponent's defensive flanks",
|
| 30 |
-
defense: "• Three CBs must stay disciplined\n• Wingers track back to help defense\n• High defensive line with offside trap",
|
| 31 |
-
keyPoints: ["• Very attacking mindset", "• Risk-reward strategy", "• Requires fit forwards"]
|
| 32 |
-
},
|
| 33 |
-
"3-2-1": {
|
| 34 |
-
name: "3-2-1 Formation",
|
| 35 |
-
summary: "Balanced with strong midfield duo supporting solo striker",
|
| 36 |
-
attack: "• Two CMs control possession\n• ST holds up play for midfield runners\n• Wing play supported by overlapping fullbacks",
|
| 37 |
-
defense: "• Three CBs with midfield screen\n• CMs drop to form 5-man defense\n• Compact central shape",
|
| 38 |
-
keyPoints: ["• Solid midfield control", "• ST as focal point", "• Flexible formation"]
|
| 39 |
-
},
|
| 40 |
-
"2-3-1": {
|
| 41 |
-
name: "2-3-1 Formation",
|
| 42 |
-
summary: "Midfield-heavy formation with diamond shape",
|
| 43 |
-
attack: "• Three CMs dominate possession\n• ST supported by attacking CM\n• Quick passing through center",
|
| 44 |
-
defense: "• Two CBs with midfield protection\n• CMs track back to form block\n• Pressure opponents in midfield",
|
| 45 |
-
keyPoints: ["• Midfield dominance", "• Short passing game", "• Compact structure"]
|
| 46 |
-
},
|
| 47 |
-
"2-2-2": {
|
| 48 |
-
name: "2-2-2 Formation",
|
| 49 |
-
summary: "Balanced formation with two banks of two",
|
| 50 |
-
attack: "• Two strikers press defenders\n• CMs support attacks with late runs\n• Width from fullbacks",
|
| 51 |
-
defense: "• Two CBs with two CM shield\n• Compact shape hard to break down\n• Counter-attack quickly",
|
| 52 |
-
keyPoints: ["• Very balanced approach", "• Hard to break down", "• Good for counter-attacks"]
|
| 53 |
-
},
|
| 54 |
-
"4-1-1": {
|
| 55 |
-
name: "4-1-1 Formation",
|
| 56 |
-
summary: "Defensive solid with CAM supporting striker",
|
| 57 |
-
attack: "• CAM creates chances for ST\n• Wingers provide crosses\n• Patient build-up play",
|
| 58 |
-
defense: "• Four defenders with CDM screen\n• Very hard to score against\n• Low block with quick transitions",
|
| 59 |
-
keyPoints: ["• Defensive stability", "• CAM key playmaker", "• Low block strategy"]
|
| 60 |
-
},
|
| 61 |
-
"3-3-0": {
|
| 62 |
-
name: "3-3-0 Formation",
|
| 63 |
-
summary: "No striker formation with three attacking midfielders",
|
| 64 |
-
attack: "• Three CAMs rotate positions\n• False nine approach\n• Fluid attacking movement",
|
| 65 |
-
defense: "• Three CBs with midfield triangle\n• Press high as unit\n• Win ball back quickly",
|
| 66 |
-
keyPoints: ["• False nine system", "• Fluid movement", "• High pressing"]
|
| 67 |
-
},
|
| 68 |
-
"2-1-3": {
|
| 69 |
-
name: "2-1-3 Formation",
|
| 70 |
-
summary: "Ultra-attacking with three forwards",
|
| 71 |
-
attack: "• Three forwards create chaos\n• Single CM distributes play\n• All-out attack mentality",
|
| 72 |
-
defense: "• Two CBs with limited protection\n• High risk defensive approach\n• Score more than you concede",
|
| 73 |
-
keyPoints: ["• Very attacking", "• High risk-high reward", "• Needs fit forwards"]
|
| 74 |
-
},
|
| 75 |
-
"1-4-1": {
|
| 76 |
-
name: "1-4-1 Formation",
|
| 77 |
-
summary: "Unconventional with single CB and packed midfield",
|
| 78 |
-
attack: "• Four midfielders control game\n• ST leads the line alone\n• Possession-based football",
|
| 79 |
-
defense: "• One CB with midfield cover\n• Packed central area\n• Frustrate opponents",
|
| 80 |
-
keyPoints: ["• Unconventional approach", "• Midfield overload", "• Possession game"]
|
| 81 |
-
},
|
| 82 |
-
"4-2-0": {
|
| 83 |
-
name: "4-2-0 Formation",
|
| 84 |
-
summary: "Defensive with no strikers, focus on clean sheets",
|
| 85 |
-
attack: "• CMs make late runs into box\n• Wingers cut inside\n• Goal from midfield",
|
| 86 |
-
defense: "• Four CBs with two shields\n• Extremely hard to break down\n• Frustrate opponents completely",
|
| 87 |
-
keyPoints: ["• Ultra-defensive", "• Clean sheet focus", "• Goals from midfield"]
|
| 88 |
-
},
|
| 89 |
-
"3-1-3": {
|
| 90 |
-
name: "3-1-3 Formation",
|
| 91 |
-
summary: "Attacking with three forwards and playmaker",
|
| 92 |
-
attack: "• Three forwards press high\n• CAM creates all chances\n• Quick combination play",
|
| 93 |
-
defense: "• Three CBs with CDM cover\n• CAM tracks back when needed\n• Compact when out of possession",
|
| 94 |
-
keyPoints: ["• Attack-minded", "• CAM key creator", "• High press"]
|
| 95 |
-
},
|
| 96 |
-
"5-0-1": {
|
| 97 |
-
name: "5-0-1 Formation",
|
| 98 |
-
summary: "Ultra-defensive with five at the back",
|
| 99 |
-
attack: "• Lone ST holds up play\n• Wingbacks provide width in attack\n• Direct balls to striker",
|
| 100 |
-
defense: "• Five defenders impossible to break\n• Very low block\n• Defensive stability priority",
|
| 101 |
-
keyPoints: ["• Ultra-defensive", "• Five at back", "• Direct attacking"]
|
| 102 |
-
},
|
| 103 |
-
"3-1-1-1": {
|
| 104 |
-
name: "3-1-1-1 Formation",
|
| 105 |
-
summary: "Christmas tree formation with three lines",
|
| 106 |
-
attack: "• CAM links midfield to attack\n• ST leads line with support\n• Patient build-up",
|
| 107 |
-
defense: "• Three CBs with double screen\n• CDM and CAM track back\n• Structured defensive shape",
|
| 108 |
-
keyPoints: ["• Christmas tree shape", "• Structured approach", "• Patient buildup"]
|
| 109 |
-
},
|
| 110 |
-
"2-2-1-1": {
|
| 111 |
-
name: "2-2-1-1 Formation",
|
| 112 |
-
summary: "Midfield diamond with two strikers",
|
| 113 |
-
attack: "• CAM feeds two strikers\n• Two CMs control tempo\n• Creative attacking play",
|
| 114 |
-
defense: "• Two CBs with diamond protection\n• Compact center\n• Press as unit",
|
| 115 |
-
keyPoints: ["• Diamond midfield", "• Two strikers", "• Creative play"]
|
| 116 |
-
},
|
| 117 |
-
"4-1-2": {
|
| 118 |
-
name: "4-1-2 Formation",
|
| 119 |
-
summary: "Defensive with two attacking midfielders",
|
| 120 |
-
attack: "• Two CAMs support ST\n• Wingers stay wide\n• Controlled attacking play",
|
| 121 |
-
defense: "• Four defenders with CDM shield\n• Very organized defense\n• Hard to break down centrally",
|
| 122 |
-
keyPoints: ["• Organized defense", "• Two creators", "• Controlled attack"]
|
| 123 |
-
},
|
| 124 |
-
"2-3-2": {
|
| 125 |
-
name: "2-3-2 Formation",
|
| 126 |
-
summary: "Midfield control with two strikers",
|
| 127 |
-
attack: "• Three CMs dominate center\n• Two strikers press high\n• Quick passing combinations",
|
| 128 |
-
defense: "• Two CBs with midfield cover\n• Press high together\n• Win ball back quickly",
|
| 129 |
-
keyPoints: ["• Midfield dominance", "• High press", "• Quick combinations"]
|
| 130 |
-
}
|
| 131 |
-
};
|
| 132 |
-
|
| 133 |
-
// Position coordinates on pitch (x, y as percentage)
|
| 134 |
-
const POSITION_COORDS = {
|
| 135 |
-
'GK': [50, 90],
|
| 136 |
-
'CB': [50, 72], 'CB1': [38, 72], 'CB2': [62, 72],
|
| 137 |
-
'LB': [15, 65], 'RB': [85, 65],
|
| 138 |
-
'LCB': [35, 72], 'RCB': [65, 72],
|
| 139 |
-
'CM': [50, 50], 'CM1': [35, 50], 'CM2': [65, 50],
|
| 140 |
-
'LCM': [30, 50], 'RCM': [70, 50],
|
| 141 |
-
'CDM': [50, 58], 'CDM1': [40, 58], 'CDM2': [60, 58],
|
| 142 |
-
'CAM': [50, 38], 'CAM1': [40, 38], 'CAM2': [60, 38],
|
| 143 |
-
'LM': [12, 50], 'RM': [88, 50],
|
| 144 |
-
'LW': [18, 30], 'RW': [82, 30],
|
| 145 |
-
'LF': [30, 30], 'RF': [70, 30],
|
| 146 |
-
'ST': [50, 20], 'ST1': [38, 20], 'ST2': [62, 20],
|
| 147 |
-
'CF': [50, 32]
|
| 148 |
-
};
|
| 149 |
-
|
| 150 |
-
function downloadImage(url) {
|
| 151 |
-
return new Promise((resolve, reject) => {
|
| 152 |
-
const client = url.startsWith('https') ? https : http;
|
| 153 |
-
client.get(url, { timeout: 5000 }, (res) => {
|
| 154 |
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
| 155 |
-
return downloadImage(res.headers.location).then(resolve).catch(reject);
|
| 156 |
-
}
|
| 157 |
-
const chunks = [];
|
| 158 |
-
res.on('data', (chunk) => chunks.push(chunk));
|
| 159 |
-
res.on('end', () => resolve(Buffer.concat(chunks)));
|
| 160 |
-
res.on('error', reject);
|
| 161 |
-
}).on('error', reject);
|
| 162 |
-
});
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
function drawPitch(ctx, W, H) {
|
| 166 |
-
// Main grass gradient
|
| 167 |
-
const grassGrad = ctx.createLinearGradient(0, 0, 0, H);
|
| 168 |
-
grassGrad.addColorStop(0, '#1a7a3a');
|
| 169 |
-
grassGrad.addColorStop(0.5, '#1e8c42');
|
| 170 |
-
grassGrad.addColorStop(1, '#1a7a3a');
|
| 171 |
-
ctx.fillStyle = grassGrad;
|
| 172 |
-
ctx.fillRect(0, 0, W, H);
|
| 173 |
-
|
| 174 |
-
// Grass stripe pattern
|
| 175 |
-
const stripeCount = 12;
|
| 176 |
-
const stripeH = H / stripeCount;
|
| 177 |
-
for (let i = 0; i < stripeCount; i++) {
|
| 178 |
-
if (i % 2 === 0) {
|
| 179 |
-
ctx.fillStyle = 'rgba(255,255,255,0.04)';
|
| 180 |
-
ctx.fillRect(0, i * stripeH, W, stripeH);
|
| 181 |
-
}
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
// Pitch outline
|
| 185 |
-
const pad = 30;
|
| 186 |
-
ctx.strokeStyle = 'rgba(255,255,255,0.85)';
|
| 187 |
-
ctx.lineWidth = 2.5;
|
| 188 |
-
ctx.strokeRect(pad, pad, W - pad * 2, H - pad * 2);
|
| 189 |
-
|
| 190 |
-
// Center line
|
| 191 |
-
ctx.beginPath();
|
| 192 |
-
ctx.moveTo(pad, H / 2);
|
| 193 |
-
ctx.lineTo(W - pad, H / 2);
|
| 194 |
-
ctx.stroke();
|
| 195 |
-
|
| 196 |
-
// Center circle
|
| 197 |
-
ctx.beginPath();
|
| 198 |
-
ctx.arc(W / 2, H / 2, 80, 0, Math.PI * 2);
|
| 199 |
-
ctx.stroke();
|
| 200 |
-
|
| 201 |
-
// Center dot
|
| 202 |
-
ctx.beginPath();
|
| 203 |
-
ctx.arc(W / 2, H / 2, 4, 0, Math.PI * 2);
|
| 204 |
-
ctx.fillStyle = 'rgba(255,255,255,0.85)';
|
| 205 |
-
ctx.fill();
|
| 206 |
-
|
| 207 |
-
// Penalty areas
|
| 208 |
-
ctx.strokeRect(W / 2 - 90, pad, 180, 120);
|
| 209 |
-
ctx.strokeRect(W / 2 - 90, H - pad - 120, 180, 120);
|
| 210 |
-
|
| 211 |
-
// Goal areas
|
| 212 |
-
ctx.strokeRect(W / 2 - 40, pad, 80, 50);
|
| 213 |
-
ctx.strokeRect(W / 2 - 40, H - pad - 50, 80, 50);
|
| 214 |
-
|
| 215 |
-
// Penalty dots
|
| 216 |
-
ctx.beginPath();
|
| 217 |
-
ctx.arc(W / 2, pad + 80, 3, 0, Math.PI * 2);
|
| 218 |
-
ctx.fill();
|
| 219 |
-
ctx.beginPath();
|
| 220 |
-
ctx.arc(W / 2, H - pad - 80, 3, 0, Math.PI * 2);
|
| 221 |
-
ctx.fill();
|
| 222 |
-
}
|
| 223 |
-
|
| 224 |
-
function drawPosition(ctx, x, y, number, label, hasPlayer, avatarBuffer) {
|
| 225 |
-
const radius = 25;
|
| 226 |
-
const canvasX = (x / 100) * 900;
|
| 227 |
-
const canvasY = (y / 100) * 600;
|
| 228 |
-
|
| 229 |
-
// Draw circle background
|
| 230 |
-
ctx.beginPath();
|
| 231 |
-
ctx.arc(canvasX, canvasY, radius, 0, Math.PI * 2);
|
| 232 |
-
ctx.fillStyle = hasPlayer ? 'rgba(46, 204, 113, 0.9)' : 'rgba(149, 165, 166, 0.7)';
|
| 233 |
-
ctx.fill();
|
| 234 |
-
ctx.strokeStyle = '#fff';
|
| 235 |
-
ctx.lineWidth = 2;
|
| 236 |
-
ctx.stroke();
|
| 237 |
-
|
| 238 |
-
// Draw number
|
| 239 |
-
ctx.fillStyle = '#fff';
|
| 240 |
-
ctx.font = 'bold 16px Arial';
|
| 241 |
-
ctx.textAlign = 'center';
|
| 242 |
-
ctx.textBaseline = 'middle';
|
| 243 |
-
ctx.fillText(number.toString(), canvasX, canvasY);
|
| 244 |
-
|
| 245 |
-
// Draw label below
|
| 246 |
-
ctx.font = '11px Arial';
|
| 247 |
-
ctx.fillStyle = '#fff';
|
| 248 |
-
ctx.fillText(label, canvasX, canvasY + radius + 15);
|
| 249 |
-
|
| 250 |
-
// Draw avatar if available
|
| 251 |
-
if (hasPlayer && avatarBuffer) {
|
| 252 |
-
try {
|
| 253 |
-
const img = new (require('@napi-rs/canvas').Image)();
|
| 254 |
-
img.src = avatarBuffer;
|
| 255 |
-
ctx.save();
|
| 256 |
-
ctx.beginPath();
|
| 257 |
-
ctx.arc(canvasX, canvasY, radius - 2, 0, Math.PI * 2);
|
| 258 |
-
ctx.closePath();
|
| 259 |
-
ctx.clip();
|
| 260 |
-
ctx.drawImage(img, canvasX - radius + 2, canvasY - radius + 2, (radius - 2) * 2, (radius - 2) * 2);
|
| 261 |
-
ctx.restore();
|
| 262 |
-
} catch (e) {
|
| 263 |
-
// Ignore avatar errors
|
| 264 |
-
}
|
| 265 |
-
}
|
| 266 |
-
}
|
| 267 |
-
|
| 268 |
-
async function createTacticAttachment(formationName, formation, lineup, tacticData, client) {
|
| 269 |
-
const W = 900, H = 600;
|
| 270 |
-
const canvas = createCanvas(W, H);
|
| 271 |
-
const ctx = canvas.getContext('2d');
|
| 272 |
-
|
| 273 |
-
// Draw pitch
|
| 274 |
-
drawPitch(ctx, W, H);
|
| 275 |
-
|
| 276 |
-
// Create position to number mapping (1-7)
|
| 277 |
-
const positionNumbers = {};
|
| 278 |
-
formation.forEach(([posKey, posLabel], index) => {
|
| 279 |
-
positionNumbers[posKey] = index + 1;
|
| 280 |
-
});
|
| 281 |
-
|
| 282 |
-
// Draw each position
|
| 283 |
-
for (const [posKey, posLabel] of formation) {
|
| 284 |
-
const coords = POSITION_COORDS[posKey];
|
| 285 |
-
if (!coords) continue;
|
| 286 |
-
|
| 287 |
-
const number = positionNumbers[posKey];
|
| 288 |
-
const players = lineup.get(posKey) || [];
|
| 289 |
-
const hasPlayer = players.length > 0;
|
| 290 |
-
let avatarBuffer = null;
|
| 291 |
-
|
| 292 |
-
// Try to load player avatar
|
| 293 |
-
if (hasPlayer && client) {
|
| 294 |
-
try {
|
| 295 |
-
const userId = players[0];
|
| 296 |
-
const user = await client.users.fetch(userId);
|
| 297 |
-
if (user.avatarURL()) {
|
| 298 |
-
avatarBuffer = await downloadImage(user.avatarURL({ format: 'png', size: 64 }));
|
| 299 |
-
}
|
| 300 |
-
} catch (e) {
|
| 301 |
-
// Ignore errors
|
| 302 |
-
}
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
drawPosition(ctx, coords[0], coords[1], number, posLabel, hasPlayer, avatarBuffer);
|
| 306 |
-
}
|
| 307 |
-
|
| 308 |
-
// Add tactic info overlay at bottom
|
| 309 |
-
ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';
|
| 310 |
-
ctx.fillRect(0, H - 80, W, 80);
|
| 311 |
-
|
| 312 |
-
ctx.fillStyle = '#fff';
|
| 313 |
-
ctx.font = 'bold 18px Arial';
|
| 314 |
-
ctx.textAlign = 'left';
|
| 315 |
-
ctx.fillText(`TACTIC: ${tacticData.name}`, 20, H - 50);
|
| 316 |
-
|
| 317 |
-
ctx.font = '12px Arial';
|
| 318 |
-
const summaryText = tacticData.summary.length > 80 ? tacticData.summary.substring(0, 80) + '...' : tacticData.summary;
|
| 319 |
-
ctx.fillText(summaryText, 20, H - 25);
|
| 320 |
-
|
| 321 |
-
return new AttachmentBuilder(canvas.toBuffer('image/png'), { name: 'tactic.png' });
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
module.exports = { TACTICS, createTacticAttachment };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tos.html
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Terms of Service - FriendlyBot</title>
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
| 8 |
-
<style>
|
| 9 |
-
:root {
|
| 10 |
-
--primary: #5865F2;
|
| 11 |
-
--bg: #0f172a;
|
| 12 |
-
--card: #1e293b;
|
| 13 |
-
--text: #f8fafc;
|
| 14 |
-
--text-muted: #94a3b8;
|
| 15 |
-
}
|
| 16 |
-
body {
|
| 17 |
-
font-family: 'Inter', sans-serif;
|
| 18 |
-
background-color: var(--bg);
|
| 19 |
-
color: var(--text);
|
| 20 |
-
line-height: 1.6;
|
| 21 |
-
margin: 0;
|
| 22 |
-
padding: 2rem;
|
| 23 |
-
display: flex;
|
| 24 |
-
justify-content: center;
|
| 25 |
-
}
|
| 26 |
-
.container {
|
| 27 |
-
max-width: 800px;
|
| 28 |
-
background: var(--card);
|
| 29 |
-
padding: 3rem;
|
| 30 |
-
border-radius: 1rem;
|
| 31 |
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 32 |
-
}
|
| 33 |
-
h1 { color: var(--primary); margin-top: 0; }
|
| 34 |
-
h2 { border-bottom: 1px solid #334155; padding-bottom: 0.5rem; margin-top: 2rem; }
|
| 35 |
-
p { color: var(--text-muted); }
|
| 36 |
-
.back-link { display: inline-block; margin-bottom: 2rem; color: var(--primary); text-decoration: none; font-weight: 600; }
|
| 37 |
-
</style>
|
| 38 |
-
</head>
|
| 39 |
-
<body>
|
| 40 |
-
<div class="container">
|
| 41 |
-
<a href="/" class="back-link">← Back to Dashboard</a>
|
| 42 |
-
<h1>Terms of Service</h1>
|
| 43 |
-
<p>Last Updated: April 24, 2026</p>
|
| 44 |
-
|
| 45 |
-
<h2>1. Acceptance of Terms</h2>
|
| 46 |
-
<p>By adding FriendlyBot to your Discord server or using its services, you agree to be bound by these Terms of Service. If you do not agree, you must remove the bot from your server immediately.</p>
|
| 47 |
-
|
| 48 |
-
<h2>2. Use of Service</h2>
|
| 49 |
-
<p>FriendlyBot is provided "as is" and "as available". We do not guarantee 100% uptime. You agree not to use the bot for any illegal activities or to violate Discord's own Terms of Service.</p>
|
| 50 |
-
|
| 51 |
-
<h2>3. Data Collection</h2>
|
| 52 |
-
<p>The bot collects and stores minimal data required for its functionality, including User IDs, Server IDs, and match statistics. By using the bot, you consent to this data collection.</p>
|
| 53 |
-
|
| 54 |
-
<h2>4. Limitations</h2>
|
| 55 |
-
<p>We are not responsible for any damage or data loss caused by the use of this bot. We reserve the right to restrict access to any server or user at our discretion.</p>
|
| 56 |
-
|
| 57 |
-
<h2>5. Changes to Terms</h2>
|
| 58 |
-
<p>We reserve the right to modify these terms at any time. Continued use of the bot after changes constitutes acceptance of the new terms.</p>
|
| 59 |
-
</div>
|
| 60 |
-
</body>
|
| 61 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ultimate_fix.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
// Clean no-op setup. Let the container handle native connections.
|
| 2 |
-
console.log(">>> [NETWORK] Using native fallback routing.");
|
| 3 |
-
|
| 4 |
-
function rotateEndpoint() {
|
| 5 |
-
return;
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
module.exports = {
|
| 9 |
-
dispatcher: null,
|
| 10 |
-
wsAgent: null,
|
| 11 |
-
rotateEndpoint
|
| 12 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
"use strict";
|
| 2 |
-
const express = require("express");
|
| 3 |
-
const path = require("path");
|
| 4 |
-
const db = require("./db");
|
| 5 |
-
|
| 6 |
-
const app = express();
|
| 7 |
-
const PORT = process.env.PORT || 7860;
|
| 8 |
-
|
| 9 |
-
app.use(express.json());
|
| 10 |
-
app.use(express.static(__dirname)); // Serve static files (html, css, js)
|
| 11 |
-
|
| 12 |
-
// API: Get all rosters
|
| 13 |
-
app.get("/api/roster", (req, res) => {
|
| 14 |
-
try {
|
| 15 |
-
const data = db.getRosters();
|
| 16 |
-
res.json(data);
|
| 17 |
-
} catch (err) {
|
| 18 |
-
console.error("[WEB] Error fetching roster:", err.message);
|
| 19 |
-
res.status(500).json({ error: "Failed to fetch roster" });
|
| 20 |
-
}
|
| 21 |
-
});
|
| 22 |
-
|
| 23 |
-
// API: Add roster (optional, mainly used by web UI if needed)
|
| 24 |
-
app.post("/api/roster", (req, res) => {
|
| 25 |
-
const { team, user, role } = req.body;
|
| 26 |
-
if (!team || !user || !role) {
|
| 27 |
-
return res.status(400).json({ error: "Missing team, user, or role" });
|
| 28 |
-
}
|
| 29 |
-
try {
|
| 30 |
-
db.addRoster(team, user, role);
|
| 31 |
-
res.json({ success: true });
|
| 32 |
-
} catch (err) {
|
| 33 |
-
console.error("[WEB] Error adding roster:", err.message);
|
| 34 |
-
res.status(500).json({ error: "Failed to add roster" });
|
| 35 |
-
}
|
| 36 |
-
});
|
| 37 |
-
|
| 38 |
-
// Serve Dashboard
|
| 39 |
-
app.get("/", (req, res) => {
|
| 40 |
-
res.sendFile(path.resolve(__dirname, "dashboard.html"));
|
| 41 |
-
});
|
| 42 |
-
|
| 43 |
-
// Serve League Page
|
| 44 |
-
app.get("/league", (req, res) => {
|
| 45 |
-
res.sendFile(path.resolve(__dirname, "league.html"));
|
| 46 |
-
});
|
| 47 |
-
|
| 48 |
-
// Serve Roster Page
|
| 49 |
-
app.get("/roster", (req, res) => {
|
| 50 |
-
res.sendFile(path.resolve(__dirname, "roster.html"));
|
| 51 |
-
});
|
| 52 |
-
|
| 53 |
-
app.listen(PORT, "0.0.0.0", () => {
|
| 54 |
-
console.log(`[WEB] Server running on port ${PORT}`);
|
| 55 |
-
console.log(`[WEB] Dashboard: http://localhost:${PORT}/`);
|
| 56 |
-
console.log(`[WEB] League: http://localhost:${PORT}/league`);
|
| 57 |
-
console.log(`[WEB] Roster: http://localhost:${PORT}/roster`);
|
| 58 |
-
});
|
| 59 |
-
|
| 60 |
-
module.exports = app;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|