From 6a576f4636406e6d80a6b2fbc22cfb6a9382196e Mon Sep 17 00:00:00 2001 From: Hipperooni <60094069+Hipperooni@users.noreply.github.com> Date: Mon, 17 Jun 2024 00:26:35 +1000 Subject: [PATCH] Important fix for karma (#789) * Important fix for karma Fixed karma not being received Made the user option in /karma optional to align with other commands * Okay --- src/discord/commands/guild/d.karma.ts | 7 ++++--- src/discord/utils/chitragupta.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/discord/commands/guild/d.karma.ts b/src/discord/commands/guild/d.karma.ts index 11d120320..7e4309d34 100644 --- a/src/discord/commands/guild/d.karma.ts +++ b/src/discord/commands/guild/d.karma.ts @@ -17,14 +17,15 @@ export const dKarma: SlashCommand = { .setDescription('Get someone\'s karma!') .addUserOption(option => option .setName('user') - .setDescription('User to lookup') - .setRequired(true)) + .setDescription('User to lookup')) .addBooleanOption(option => option.setName('ephemeral') .setDescription('Set to "True" to show the response only to you')), async execute(interaction) { log.info(F, await commandContext(interaction)); await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); - const member = interaction.options.getMember('user') as GuildMember; + const member = interaction.options.getMember('target') + ? interaction.options.getMember('target') as GuildMember + : interaction.member as GuildMember; const userData = await db.users.upsert({ where: { diff --git a/src/discord/utils/chitragupta.ts b/src/discord/utils/chitragupta.ts index 4734928e8..fd57ad90c 100644 --- a/src/discord/utils/chitragupta.ts +++ b/src/discord/utils/chitragupta.ts @@ -38,8 +38,9 @@ export async function chitragupta( // log.debug(F, `actor: ${actor}`); if (!reaction.emoji.name) return; if (!reaction.emoji.name.includes('upvote')) return; + // log.debug(F, `actor: ${actor.username} target: ${target.username} action: ${action}`); - // Increment karma of the actor + // Increment karma given of the actor await db.users.upsert({ where: { discord_id: actor.id }, create: { @@ -56,7 +57,7 @@ export async function chitragupta( // const actorData = await getUser(actor.id, null, null); - // Increment the karma of the target + // Increment the karma received of the target await db.users.upsert({ where: { discord_id: target.id }, create: { @@ -65,7 +66,7 @@ export async function chitragupta( karma_received: action, }, update: { - karma_given: { + karma_received: { increment: action, }, },