diff --git a/_opt/responses.js b/_opt/responses.js index 27d7120..f8ea07b 100644 --- a/_opt/responses.js +++ b/_opt/responses.js @@ -271,18 +271,20 @@ async function onMessage(client, cfg, message) { // Previous response ID for context continuity const prev = client.pb?.cache?.get(key); // Enforce minimum score to use AI responses - // Enforce minimum score to use AI responses, but allow guild admins - try { - const isAdmin = message.member?.permissions?.has(PermissionFlagsBits.Administrator); - const scoreData = await client.scorekeeper.getScore(message.guild.id, message.author.id); - if (!isAdmin && scoreData.totalScore < cfg.minScore) { - await message.reply( - `You need an I/O score of at least ${cfg.minScore} to use AI responses. Your current I/O score is ${scoreData.totalScore.toFixed(2)}.` - ); - return; + // Enforce minimum score to use AI responses if scorekeeper is enabled + if (client.scorekeeper) { + try { + const isAdmin = message.member?.permissions?.has(PermissionFlagsBits.Administrator); + const scoreData = await client.scorekeeper.getScore(message.guild.id, message.author.id); + if (!isAdmin && scoreData.totalScore < cfg.minScore) { + await message.reply( + `You need an I/O score of at least ${cfg.minScore} to use AI responses. Your current I/O score is ${scoreData.totalScore.toFixed(2)}.` + ); + return; + } + } catch (err) { + client.logger.error(`Error checking score: ${err.message}`); } - } catch (err) { - client.logger.error(`Error checking score: ${err.message}`); } // Build request body, prefixing with a mention of who spoke const speakerMention = `<@${message.author.id}>`; diff --git a/_opt/responsesQuery.js b/_opt/responsesQuery.js index 031aeb6..1bfdc14 100644 --- a/_opt/responsesQuery.js +++ b/_opt/responsesQuery.js @@ -169,19 +169,21 @@ export const commands = [ ), async execute(interaction, client) { const cfg = client.config.responses; - // Enforce minimum score to use /query, allow guild admins to bypass - try { - const isAdmin = interaction.member?.permissions?.has(PermissionFlagsBits.Administrator); - const scoreData = await client.scorekeeper.getScore(interaction.guildId, interaction.user.id); - if (!isAdmin && scoreData.totalScore < cfg.minScore) { - return interaction.reply({ - content: `You need an I/O score of at least ${cfg.minScore} to use /query. Your current I/O score is ${scoreData.totalScore.toFixed(2)}.`, - ephemeral: true - }); + // Enforce minimum score to use /query if scorekeeper is enabled + if (client.scorekeeper) { + try { + const isAdmin = interaction.member?.permissions?.has(PermissionFlagsBits.Administrator); + const scoreData = await client.scorekeeper.getScore(interaction.guildId, interaction.user.id); + if (!isAdmin && scoreData.totalScore < cfg.minScore) { + return interaction.reply({ + content: `You need an I/O score of at least ${cfg.minScore} to use /query. Your current I/O score is ${scoreData.totalScore.toFixed(2)}.`, + ephemeral: true + }); + } + } catch (err) { + client.logger.error(`Error checking score: ${err.message}`); + return interaction.reply({ content: 'Error verifying your score. Please try again later.', ephemeral: true }); } - } catch (err) { - client.logger.error(`Error checking score: ${err.message}`); - return interaction.reply({ content: 'Error verifying your score. Please try again later.', ephemeral: true }); } const prompt = interaction.options.getString('prompt'); const flag = interaction.options.getBoolean('ephemeral'); diff --git a/_opt/scorekeeper.js b/_opt/scorekeeper.js index 6508d84..c4032c2 100644 --- a/_opt/scorekeeper.js +++ b/_opt/scorekeeper.js @@ -425,26 +425,23 @@ export const commands = [ const scoreData = await client.scorekeeper.getScore(interaction.guildId, targetUser.id); const multiplierValue = 1 + (scoreData.commendations * commendationValue) - (scoreData.citations * citationValue); const embed = new EmbedBuilder() + .setAuthor({ name: `${client.user.username}: Scorekeeper Module`, iconURL: client.user.displayAvatarURL() }) .setTitle(`I/O Score for ${(await interaction.guild.members.fetch(targetUser.id).catch(() => null))?.displayName || targetUser.username}`) - .setColor(0x00AE86) - .setThumbnail(targetUser.displayAvatarURL()) + .setColor(0x00AE86) + .setThumbnail(targetUser.displayAvatarURL()) + .setDescription('I/O is a mechanism to rank the users within a system based on the resources they put into the system and the resources they take from it. The resulting priority score can be used for a variety of dystopian purposes.') .addFields( - { name: 'Total Score', value: `**${scoreData.totalScore.toFixed(2)}**`, inline: false }, { name: 'Commendations', value: `**${scoreData.commendations}**`, inline: false }, { name: 'Citations', value: `**${scoreData.citations}**`, inline: false }, - { name: 'Input Score', value: `**${scoreData.input}**`, inline: true }, - { name: 'Output Score', value: `**${scoreData.output}**`, inline: true } + { name: 'Input', value: `${scoreData.input}`, inline: true }, + { name: 'Output', value: `${scoreData.output}`, inline: true }, + { name: 'Priority Score', value: `${scoreData.totalScore.toFixed(2)}`, inline: true }, + { name: 'Base Output', value: `-# ${baseOutput}`, inline: true }, + { name: 'Commendation Value', value: `-# ${commendationValue}`, inline: true }, + { name: 'Citation Value', value: `-# ${citationValue}`, inline: true }, + { name: 'Multiplier Formula', value: `-# 1 + (${scoreData.commendations} * ${commendationValue}) - (${scoreData.citations} * ${citationValue}) = ${multiplierValue.toFixed(2)}`, inline: false }, + { name: 'Priority Score Formula', value: `-# ${multiplierValue.toFixed(2)} × ${scoreData.input} / (${scoreData.output} + ${baseOutput}) = ${scoreData.totalScore.toFixed(2)}`, inline: false }, ) - .addFields({ - name: 'Formula', - value: - `CV = ${commendationValue}\n` + - `CiV = ${citationValue}\n` + - `BO = ${baseOutput}\n` + - `M = 1 + **${scoreData.commendations}** × CV - **${scoreData.citations}** × CiV\n` + - `M × **${scoreData.input}** / (**${scoreData.output}** + BO) = **${scoreData.totalScore.toFixed(2)}**`, - inline: false - }) .setFooter({ text: 'Last decay: ' + new Date(scoreData.lastDecay).toLocaleDateString() }) .setTimestamp(); @@ -494,7 +491,8 @@ export const commands = [ leaderboardText += `${i + 1}. **${displayName}**: ${score.totalScore.toFixed(2)}\n`; } - const embed = new EmbedBuilder() + const embed = new EmbedBuilder() + .setAuthor({ name: `${client.user.username}: Scorekeeper Module`, iconURL: client.user.displayAvatarURL() }) .setTitle('I/O Score Leaderboard') .setColor(0x00AE86) .setDescription(leaderboardText)