diff --git a/aethex-bot/listeners/reactionXp.js b/aethex-bot/listeners/reactionXp.js index cb48847..3171073 100644 --- a/aethex-bot/listeners/reactionXp.js +++ b/aethex-bot/listeners/reactionXp.js @@ -47,13 +47,16 @@ module.exports = { const receiverOnCooldown = now - lastReceiverXp < cooldownMs || now - lastMessageXp < cooldownMs; try { + const giverMember = await reaction.message.guild.members.fetch(user.id).catch(() => null); + const receiverMember = await reaction.message.guild.members.fetch(messageAuthor.id).catch(() => null); + if (!giverOnCooldown && giverXp > 0) { - await grantXp(supabase, user.id, giverXp, client); + await grantXp(supabase, user.id, giverXp, client, giverMember, config); reactionCooldowns.set(cooldownKeyGiver, now); } if (!receiverOnCooldown && receiverXp > 0) { - await grantXp(supabase, messageAuthor.id, receiverXp, client); + await grantXp(supabase, messageAuthor.id, receiverXp, client, receiverMember, config); reactionCooldowns.set(cooldownKeyReceiver, now); reactionCooldowns.set(cooldownKeyMessage, now); } @@ -63,7 +66,7 @@ module.exports = { } }; -async function grantXp(supabase, discordUserId, xpAmount, client) { +async function grantXp(supabase, discordUserId, xpAmount, client, member, config) { const { data: link, error: linkError } = await supabase .from('discord_links') .select('user_id') @@ -80,8 +83,27 @@ async function grantXp(supabase, discordUserId, xpAmount, client) { if (profileError || !profile) return; + let finalXp = xpAmount; + + if (member && config) { + const multiplierRoles = config.multiplier_roles || []; + let highestMultiplier = 1; + + for (const mr of multiplierRoles) { + if (member.roles?.cache?.has(mr.role_id)) { + highestMultiplier = Math.max(highestMultiplier, mr.multiplier); + } + } + + if (member.premiumSince) { + highestMultiplier = Math.max(highestMultiplier, 1.5); + } + + finalXp = Math.floor(xpAmount * highestMultiplier); + } + const currentXp = profile.xp || 0; - const newXp = currentXp + xpAmount; + const newXp = currentXp + finalXp; const { error: updateError } = await supabase .from('user_profiles') @@ -91,7 +113,7 @@ async function grantXp(supabase, discordUserId, xpAmount, client) { if (updateError) return; if (client.trackXP) { - client.trackXP(xpAmount); + client.trackXP(finalXp); } } diff --git a/aethex-bot/listeners/voiceXp.js b/aethex-bot/listeners/voiceXp.js index e4dfa0b..a72c05b 100644 --- a/aethex-bot/listeners/voiceXp.js +++ b/aethex-bot/listeners/voiceXp.js @@ -164,6 +164,12 @@ async function grantVoiceXp(supabase, client, guildId, userId, config, member, m highestMultiplier = Math.max(highestMultiplier, mr.multiplier); } } + + // Server boosters get 1.5x XP bonus automatically + if (member?.premiumSince) { + highestMultiplier = Math.max(highestMultiplier, 1.5); + } + xpGain = Math.floor(xpGain * highestMultiplier); const currentXp = profile.xp || 0; diff --git a/aethex-bot/listeners/xpTracker.js b/aethex-bot/listeners/xpTracker.js index fada51c..f81fc16 100644 --- a/aethex-bot/listeners/xpTracker.js +++ b/aethex-bot/listeners/xpTracker.js @@ -63,6 +63,12 @@ module.exports = { highestMultiplier = Math.max(highestMultiplier, mr.multiplier); } } + + // Server boosters get 1.5x XP bonus automatically + if (message.member?.premiumSince) { + highestMultiplier = Math.max(highestMultiplier, 1.5); + } + xpGain = Math.floor(xpGain * highestMultiplier); const currentXp = profile.xp || 0;