Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Important fix for karma #789

Merged
merged 2 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 4 additions & 3 deletions src/discord/utils/chitragupta.ts
Original file line number Diff line number Diff line change
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
Loading