Update XP settings to include new configuration options and improve existing ones
Refactor `aethex-bot/public/dashboard.html` to update XP settings UI and `aethex-bot/server/webServer.js` to handle new XP configuration parameters, including enabling/disabling XP, message XP, reaction XP, and leveling difficulty. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 4e47823a-b103-49a5-a57b-388765b0bcd5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/oWFvNCu Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
3691dc4b08
commit
ab7fdce9dd
3 changed files with 95 additions and 76 deletions
6
.replit
6
.replit
|
|
@ -1,5 +1,5 @@
|
|||
entrypoint = "aethex-bot/bot.js"
|
||||
modules = ["nodejs-20"]
|
||||
modules = ["nodejs-20", "postgresql-16"]
|
||||
|
||||
hidden = [".pythonlibs"]
|
||||
|
||||
|
|
@ -21,6 +21,10 @@ externalPort = 80
|
|||
localPort = 8080
|
||||
externalPort = 8080
|
||||
|
||||
[[ports]]
|
||||
localPort = 41927
|
||||
externalPort = 3000
|
||||
|
||||
[workflows]
|
||||
runButton = "Project"
|
||||
|
||||
|
|
|
|||
|
|
@ -1168,6 +1168,32 @@
|
|||
</div>
|
||||
|
||||
<form id="xpSettingsForm" class="admin-form">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">General Settings</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label class="form-toggle">
|
||||
<input type="checkbox" id="xpEnabled" name="xp_enabled" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Enable XP System</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="levelCurve">Leveling Difficulty</label>
|
||||
<select id="levelCurve" name="level_curve" class="form-input">
|
||||
<option value="easy">Easy (50 XP base)</option>
|
||||
<option value="normal" selected>Normal (100 XP base)</option>
|
||||
<option value="hard">Hard (200 XP base)</option>
|
||||
</select>
|
||||
<span class="form-hint">Formula: level = sqrt(xp / base)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Message XP</h3>
|
||||
|
|
@ -1175,18 +1201,13 @@
|
|||
<div class="card-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="xpMsgMin">Minimum XP per Message</label>
|
||||
<input type="number" id="xpMsgMin" name="message_xp_min" min="0" max="1000" value="15" class="form-input">
|
||||
<span class="form-hint">Minimum XP earned per message</span>
|
||||
<label for="messageXp">XP per Message</label>
|
||||
<input type="number" id="messageXp" name="message_xp" min="0" max="1000" value="15" class="form-input">
|
||||
<span class="form-hint">XP earned per message</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xpMsgMax">Maximum XP per Message</label>
|
||||
<input type="number" id="xpMsgMax" name="message_xp_max" min="0" max="1000" value="25" class="form-input">
|
||||
<span class="form-hint">Maximum XP earned per message</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xpMsgCooldown">Message Cooldown (seconds)</label>
|
||||
<input type="number" id="xpMsgCooldown" name="message_cooldown" min="0" max="3600" value="60" class="form-input">
|
||||
<label for="messageCooldown">Message Cooldown (seconds)</label>
|
||||
<input type="number" id="messageCooldown" name="message_cooldown" min="0" max="3600" value="60" class="form-input">
|
||||
<span class="form-hint">Time between earning XP from messages</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1195,24 +1216,31 @@
|
|||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Other XP Sources</h3>
|
||||
<h3 class="card-title">Reaction XP</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="xpReaction">XP per Reaction</label>
|
||||
<input type="number" id="xpReaction" name="reaction_xp" min="0" max="100" value="5" class="form-input">
|
||||
<label class="form-toggle">
|
||||
<input type="checkbox" id="reactionXpEnabled" name="reaction_xp_enabled" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Enable Reaction XP</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="reactionXpGiven">XP for Giving Reactions</label>
|
||||
<input type="number" id="reactionXpGiven" name="reaction_xp_given" min="0" max="100" value="2" class="form-input">
|
||||
<span class="form-hint">XP earned when you react to a message</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="reactionXpReceived">XP for Receiving Reactions</label>
|
||||
<input type="number" id="reactionXpReceived" name="reaction_xp_received" min="0" max="100" value="5" class="form-input">
|
||||
<span class="form-hint">XP earned when someone reacts to your message</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xpVoice">XP per Voice Minute</label>
|
||||
<input type="number" id="xpVoice" name="voice_xp_per_minute" min="0" max="100" value="2" class="form-input">
|
||||
<span class="form-hint">XP earned per minute in voice channels</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xpDaily">Daily Claim XP</label>
|
||||
<input type="number" id="xpDaily" name="daily_xp" min="0" max="10000" value="100" class="form-input">
|
||||
<span class="form-hint">XP from daily claim command</span>
|
||||
<label for="reactionCooldown">Reaction Cooldown (seconds)</label>
|
||||
<input type="number" id="reactionCooldown" name="reaction_cooldown" min="0" max="3600" value="30" class="form-input">
|
||||
<span class="form-hint">Time between earning reaction XP</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1220,55 +1248,37 @@
|
|||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Level-Up Settings</h3>
|
||||
<h3 class="card-title">Level-Up Announcements</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="xpBase">XP Base Difficulty</label>
|
||||
<input type="number" id="xpBase" name="xp_base" min="50" max="500" value="100" class="form-input">
|
||||
<span class="form-hint">Higher = slower leveling (formula: level = sqrt(xp/base))</span>
|
||||
<label for="levelupChannelId">Announcement Channel ID</label>
|
||||
<input type="text" id="levelupChannelId" name="levelup_channel_id" placeholder="Leave blank for current channel" class="form-input">
|
||||
<span class="form-hint">Channel ID for level-up messages</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="levelUpChannel">Level-Up Announcement Channel</label>
|
||||
<select id="levelUpChannel" name="levelup_channel_id" class="form-input">
|
||||
<option value="">Current Channel</option>
|
||||
</select>
|
||||
<span class="form-hint">Where to announce level-ups</span>
|
||||
<label for="levelupMessage">Custom Level-Up Message</label>
|
||||
<input type="text" id="levelupMessage" name="levelup_message" placeholder="{user} reached level {level}!" class="form-input">
|
||||
<span class="form-hint">Use {user}, {level}, {xp} placeholders</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-toggle">
|
||||
<input type="checkbox" id="levelUpEnabled" name="levelup_enabled" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Enable Level-Up Messages</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-toggle">
|
||||
<input type="checkbox" id="levelUpDm" name="levelup_dm">
|
||||
<input type="checkbox" id="levelupDm" name="levelup_dm">
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Send Level-Up via DM</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">XP Multipliers</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="xpMultiplier">Global XP Multiplier</label>
|
||||
<input type="number" id="xpMultiplier" name="xp_multiplier" min="0.1" max="10" step="0.1" value="1.0" class="form-input">
|
||||
<span class="form-hint">Multiplies all XP earned (1.0 = normal)</span>
|
||||
<label class="form-toggle">
|
||||
<input type="checkbox" id="levelupEmbed" name="levelup_embed" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Use Rich Embed</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="weekendMultiplier">Weekend Multiplier</label>
|
||||
<input type="number" id="weekendMultiplier" name="weekend_multiplier" min="1" max="10" step="0.1" value="1.5" class="form-input">
|
||||
<span class="form-hint">Extra multiplier on weekends</span>
|
||||
<label for="levelupEmbedColor">Embed Color</label>
|
||||
<input type="color" id="levelupEmbedColor" name="levelup_embed_color" value="#7c3aed" class="form-input" style="height:40px;padding:4px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -499,41 +499,47 @@ function createWebServer(discordClient, supabase, options = {}) {
|
|||
}
|
||||
|
||||
const {
|
||||
message_xp_min,
|
||||
message_xp_max,
|
||||
message_xp,
|
||||
message_cooldown,
|
||||
reaction_xp,
|
||||
voice_xp_per_minute,
|
||||
daily_xp,
|
||||
xp_base,
|
||||
reaction_xp_enabled,
|
||||
reaction_xp_given,
|
||||
reaction_xp_received,
|
||||
reaction_cooldown,
|
||||
level_curve,
|
||||
xp_enabled,
|
||||
levelup_channel_id,
|
||||
levelup_enabled,
|
||||
levelup_message,
|
||||
levelup_dm,
|
||||
xp_multiplier,
|
||||
weekend_multiplier
|
||||
levelup_embed,
|
||||
levelup_embed_color,
|
||||
multiplier_roles,
|
||||
bonus_channels
|
||||
} = req.body;
|
||||
|
||||
try {
|
||||
const { data: existing } = await supabase
|
||||
.from('xp_config')
|
||||
.select('id')
|
||||
.select('guild_id')
|
||||
.eq('guild_id', guildId)
|
||||
.maybeSingle();
|
||||
|
||||
const configData = {
|
||||
guild_id: guildId,
|
||||
message_xp_min: message_xp_min ?? 15,
|
||||
message_xp_max: message_xp_max ?? 25,
|
||||
message_xp: message_xp ?? 15,
|
||||
message_cooldown: message_cooldown ?? 60,
|
||||
reaction_xp: reaction_xp ?? 5,
|
||||
voice_xp_per_minute: voice_xp_per_minute ?? 2,
|
||||
daily_xp: daily_xp ?? 100,
|
||||
xp_base: xp_base ?? 100,
|
||||
reaction_xp_enabled: reaction_xp_enabled !== false,
|
||||
reaction_xp_given: reaction_xp_given ?? 2,
|
||||
reaction_xp_received: reaction_xp_received ?? 5,
|
||||
reaction_cooldown: reaction_cooldown ?? 30,
|
||||
level_curve: level_curve || 'normal',
|
||||
xp_enabled: xp_enabled !== false,
|
||||
levelup_channel_id: levelup_channel_id || null,
|
||||
levelup_enabled: levelup_enabled !== false,
|
||||
levelup_message: levelup_message || null,
|
||||
levelup_dm: levelup_dm === true,
|
||||
xp_multiplier: xp_multiplier ?? 1.0,
|
||||
weekend_multiplier: weekend_multiplier ?? 1.5,
|
||||
levelup_embed: levelup_embed !== false,
|
||||
levelup_embed_color: levelup_embed_color || '#7c3aed',
|
||||
multiplier_roles: multiplier_roles || [],
|
||||
bonus_channels: bonus_channels || [],
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
|
||||
|
|
@ -545,7 +551,6 @@ function createWebServer(discordClient, supabase, options = {}) {
|
|||
|
||||
if (error) throw error;
|
||||
} else {
|
||||
configData.created_at = new Date().toISOString();
|
||||
const { error } = await supabase
|
||||
.from('xp_config')
|
||||
.insert(configData);
|
||||
|
|
@ -556,7 +561,7 @@ function createWebServer(discordClient, supabase, options = {}) {
|
|||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Failed to save XP config:', error);
|
||||
res.status(500).json({ error: 'Failed to save settings' });
|
||||
res.status(500).json({ error: 'Failed to save settings', details: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue