Skip to content

Commit

Permalink
Important fix for karma
Browse files Browse the repository at this point in the history
Fixed karma not being received
Made the user option in /karma optional to align with other commands
  • Loading branch information
Hipperooni committed Jun 11, 2024
1 parent b8bd092 commit 2c93d3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/discord/commands/guild/d.karma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
9 changes: 5 additions & 4 deletions src/discord/utils/chitragupta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
User,
} from 'discord.js';

// const F = f(__filename);
const F = f(__filename);

Check failure on line 7 in src/discord/utils/chitragupta.ts

View workflow job for this annotation

GitHub Actions / Lint

'F' is assigned a value but never used

export default chitragupta;

Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -65,7 +66,7 @@ export async function chitragupta(
karma_received: action,
},
update: {
karma_given: {
karma_received: {
increment: action,
},
},
Expand Down

0 comments on commit 2c93d3f

Please sign in to comment.