Implement tiered access and server verification for bot features
Introduces a tiered access system for bot features, distinguishing between free, federation (verified), and premium tiers. Updates `federationProtection.js` to check server verification status and `bot.js` to handle Aethex official guilds and server tier checks. Modifies `replit.md` to reflect the new tiered access model and access requirements. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 6a0de952-f48b-480a-b732-18d6f0f9f79a Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/W0QYEBv Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
c92fca9425
commit
56a8ae2e23
3 changed files with 180 additions and 21 deletions
|
|
@ -485,10 +485,11 @@ const REALM_GUILDS = {
|
|||
client.REALM_GUILDS = REALM_GUILDS;
|
||||
|
||||
// =============================================================================
|
||||
// GUILD WHITELIST SYSTEM
|
||||
// TIERED ACCESS SYSTEM (Open Bot with Federation Gating)
|
||||
// =============================================================================
|
||||
|
||||
const WHITELISTED_GUILDS = [
|
||||
// Core AeThex servers - auto-verified for federation
|
||||
const AETHEX_OFFICIAL_GUILDS = [
|
||||
'373713073594302464', // AeThex | Corporation
|
||||
'515711457946632232', // AeThex (Main)
|
||||
'525971009313046529', // AeThex | Nexus
|
||||
|
|
@ -497,10 +498,68 @@ const WHITELISTED_GUILDS = [
|
|||
'1284290638564687925', // AeThex | DevOps
|
||||
'1338564560277344287', // AeThex | Foundation
|
||||
'352519501201539072', // AeThex | Lone Star Studio
|
||||
|
||||
...(process.env.EXTRA_WHITELISTED_GUILDS || '').split(',').filter(Boolean),
|
||||
];
|
||||
client.WHITELISTED_GUILDS = WHITELISTED_GUILDS;
|
||||
client.AETHEX_OFFICIAL_GUILDS = AETHEX_OFFICIAL_GUILDS;
|
||||
|
||||
// Check if a server is federation-verified (cached for performance)
|
||||
const federationCache = new Map();
|
||||
client.federationCache = federationCache;
|
||||
|
||||
async function isServerFederationVerified(guildId) {
|
||||
if (AETHEX_OFFICIAL_GUILDS.includes(guildId)) return true;
|
||||
|
||||
if (federationCache.has(guildId)) {
|
||||
const cached = federationCache.get(guildId);
|
||||
if (Date.now() - cached.timestamp < 5 * 60 * 1000) {
|
||||
return cached.verified;
|
||||
}
|
||||
}
|
||||
|
||||
if (!supabase) return false;
|
||||
|
||||
try {
|
||||
const { data } = await supabase
|
||||
.from('federation_servers')
|
||||
.select('verified, tier')
|
||||
.eq('guild_id', guildId)
|
||||
.maybeSingle();
|
||||
|
||||
const verified = data?.verified === true;
|
||||
federationCache.set(guildId, { verified, tier: data?.tier || 'free', timestamp: Date.now() });
|
||||
return verified;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
client.isServerFederationVerified = isServerFederationVerified;
|
||||
|
||||
async function getServerTier(guildId) {
|
||||
if (AETHEX_OFFICIAL_GUILDS.includes(guildId)) return 'official';
|
||||
|
||||
if (federationCache.has(guildId)) {
|
||||
const cached = federationCache.get(guildId);
|
||||
if (Date.now() - cached.timestamp < 5 * 60 * 1000) {
|
||||
return cached.tier || 'free';
|
||||
}
|
||||
}
|
||||
|
||||
if (!supabase) return 'free';
|
||||
|
||||
try {
|
||||
const { data } = await supabase
|
||||
.from('federation_servers')
|
||||
.select('verified, tier')
|
||||
.eq('guild_id', guildId)
|
||||
.maybeSingle();
|
||||
|
||||
const tier = data?.tier || 'free';
|
||||
federationCache.set(guildId, { verified: data?.verified, tier, timestamp: Date.now() });
|
||||
return tier;
|
||||
} catch (e) {
|
||||
return 'free';
|
||||
}
|
||||
}
|
||||
client.getServerTier = getServerTier;
|
||||
|
||||
client.on('error', (error) => {
|
||||
console.error('[Discord] Client error:', error.message);
|
||||
|
|
@ -513,17 +572,64 @@ client.on('warn', (warning) => {
|
|||
});
|
||||
|
||||
client.on('guildCreate', async (guild) => {
|
||||
if (!WHITELISTED_GUILDS.includes(guild.id)) {
|
||||
console.log(`[Whitelist] Unauthorized server detected: ${guild.name} (${guild.id}) - Leaving...`);
|
||||
console.log(`[Guild] Joined new server: ${guild.name} (${guild.id}) - ${guild.memberCount} members`);
|
||||
|
||||
// Create default server config
|
||||
if (supabase) {
|
||||
try {
|
||||
await supabase.from('server_config').upsert({
|
||||
guild_id: guild.id,
|
||||
guild_name: guild.name,
|
||||
created_at: new Date().toISOString()
|
||||
}, { onConflict: 'guild_id' });
|
||||
} catch (e) {
|
||||
console.warn('[Guild] Could not create server config:', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Send welcome message to server owner or first available channel
|
||||
const welcomeEmbed = {
|
||||
color: 0x4A90E2,
|
||||
title: '👋 Thanks for adding AeThex Bot!',
|
||||
description: `Hello **${guild.name}**! I'm now ready to help your community grow with XP, leveling, music, and moderation features.`,
|
||||
fields: [
|
||||
{
|
||||
name: '🎮 Core Features (Available Now)',
|
||||
value: '• XP & Leveling System\n• Music Player\n• Basic Moderation\n• Achievements & Quests\n• Welcome/Goodbye Messages',
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '🛡️ Federation Features',
|
||||
value: '• Cross-server ban sync\n• Reputation network\n• Sentinel protection\n• Premium slots\n\n*Requires verification*',
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: '🚀 Getting Started',
|
||||
value: '1. Use `/help` to see all commands\n2. Use `/config` to set up your server\n3. Use `/federation apply` to join the protection network'
|
||||
},
|
||||
{
|
||||
name: '📖 Need Help?',
|
||||
value: '[Documentation](https://bot.aethex.dev/commands) • [Support Server](https://discord.gg/aethex)'
|
||||
}
|
||||
],
|
||||
footer: { text: 'AeThex Bot • Powering Communities' },
|
||||
timestamp: new Date().toISOString()
|
||||
};
|
||||
|
||||
try {
|
||||
const owner = await guild.fetchOwner();
|
||||
await owner.send(`Your server "${guild.name}" is not authorized to use AeThex Bot. The bot has automatically left. Contact the AeThex team if you believe this is an error.`).catch(() => {});
|
||||
} catch (e) {}
|
||||
await guild.leave();
|
||||
console.log(`[Whitelist] Left unauthorized server: ${guild.name}`);
|
||||
return;
|
||||
await owner.send({ embeds: [welcomeEmbed] });
|
||||
} catch (e) {
|
||||
// Try to find a system channel or first text channel
|
||||
const channel = guild.systemChannel || guild.channels.cache.find(
|
||||
c => c.type === 0 && c.permissionsFor(guild.members.me)?.has('SendMessages')
|
||||
);
|
||||
if (channel) {
|
||||
try {
|
||||
await channel.send({ embeds: [welcomeEmbed] });
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
console.log(`[Whitelist] Joined authorized server: ${guild.name} (${guild.id})`);
|
||||
});
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -2126,21 +2232,31 @@ const httpServer = http.createServer((req, res) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// GET /whitelist - Get whitelisted servers and users
|
||||
// GET /servers - Get official AeThex servers and all connected servers
|
||||
if (req.url === "/whitelist" && req.method === "GET") {
|
||||
const whitelistedServers = WHITELISTED_GUILDS.map(guildId => {
|
||||
const officialServers = AETHEX_OFFICIAL_GUILDS.map(guildId => {
|
||||
const guild = client.guilds.cache.get(guildId);
|
||||
return {
|
||||
id: guildId,
|
||||
name: guild?.name || 'Not Connected',
|
||||
memberCount: guild?.memberCount || 0,
|
||||
connected: !!guild,
|
||||
official: true,
|
||||
};
|
||||
});
|
||||
|
||||
const allServers = client.guilds.cache.map(guild => ({
|
||||
id: guild.id,
|
||||
name: guild.name,
|
||||
memberCount: guild.memberCount,
|
||||
connected: true,
|
||||
official: AETHEX_OFFICIAL_GUILDS.includes(guild.id),
|
||||
}));
|
||||
|
||||
res.writeHead(200);
|
||||
res.end(JSON.stringify({
|
||||
servers: whitelistedServers,
|
||||
officialServers,
|
||||
allServers,
|
||||
users: whitelistedUsers.map(id => ({ id, note: 'Whitelisted User' })),
|
||||
timestamp: new Date().toISOString(),
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -8,14 +8,19 @@ module.exports = {
|
|||
if (!supabase) return;
|
||||
|
||||
try {
|
||||
// Check if server is federation-verified (uses cache for performance)
|
||||
const isVerified = await client.isServerFederationVerified?.(member.guild.id);
|
||||
if (!isVerified) return;
|
||||
|
||||
const { data: serverConfig } = await supabase
|
||||
.from('federation_servers')
|
||||
.select('tier, status, trust_level, reputation_score')
|
||||
.select('tier, status, trust_level, reputation_score, verified')
|
||||
.eq('guild_id', member.guild.id)
|
||||
.eq('status', 'approved')
|
||||
.maybeSingle();
|
||||
|
||||
if (!serverConfig) return;
|
||||
// Double-check verification at database level
|
||||
if (!serverConfig || serverConfig.verified !== true) return;
|
||||
|
||||
const { data: ban } = await supabase
|
||||
.from('federation_bans')
|
||||
|
|
|
|||
40
replit.md
40
replit.md
|
|
@ -5,7 +5,8 @@
|
|||
The AeThex Unified Bot is a comprehensive, production-ready Discord bot powering the entire AeThex ecosystem. It provides enterprise-level security, cross-server federation, community engagement features, and multi-purpose server management—all unified into a single powerful instance.
|
||||
|
||||
### Current Status
|
||||
- **Servers:** 7 official AeThex servers (Corporation, Main, Nexus, GameForge, LABS, DevOps, Foundation)
|
||||
- **Access:** Open to all Discord servers (tiered feature access)
|
||||
- **Official Servers:** 8 AeThex servers (Corporation, Main, Nexus, GameForge, LABS, DevOps, Foundation, Lone Star Studio)
|
||||
- **Commands:** 76 fully implemented slash commands
|
||||
- **Database:** Supabase (PostgreSQL) with 30+ tables
|
||||
- **Music:** Dual Lavalink nodes for high-availability streaming
|
||||
|
|
@ -14,6 +15,43 @@ The AeThex Unified Bot is a comprehensive, production-ready Discord bot powering
|
|||
|
||||
---
|
||||
|
||||
## Tiered Access Model
|
||||
|
||||
The bot is now **publicly available** for any Discord server to add. Features are organized into tiers:
|
||||
|
||||
### Free Tier (All Servers)
|
||||
All servers get immediate access to core features:
|
||||
- XP & Leveling System
|
||||
- Music Player (YouTube, Spotify, SoundCloud)
|
||||
- Basic Moderation (warn, kick, ban, timeout)
|
||||
- Achievements & Quests
|
||||
- Welcome/Goodbye Messages
|
||||
- Polls, Embeds, Announcements
|
||||
- Daily Rewards & Shop System
|
||||
|
||||
### Federation Tier (Verified Servers)
|
||||
Servers can apply to join the Federation network for advanced protection:
|
||||
- Cross-server ban synchronization
|
||||
- Global reputation tracking
|
||||
- Sentinel threat detection
|
||||
- Trust level progression
|
||||
- Cross-server role sync
|
||||
- Server directory listing
|
||||
|
||||
**How to Join:** Use `/federation membership apply` to submit an application.
|
||||
|
||||
### Premium Tier ($50/month)
|
||||
Verified federation servers can upgrade for enhanced protection:
|
||||
- Auto-kick/ban for ALL severity levels (not just critical)
|
||||
- Featured server slots
|
||||
- Priority support
|
||||
- Advanced analytics
|
||||
|
||||
### Official Tier
|
||||
AeThex-owned servers have full access to all features automatically.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Unified XP & Leveling System
|
||||
|
|
|
|||
Loading…
Reference in a new issue