Skip to content

Commit 367108e

Browse files
committed
fix total count
1 parent b238da7 commit 367108e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

interactions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ export async function handleInteraction(interaction: Interaction) {
475475
.then(res => res.json())
476476
.then(data => {
477477
if (data.response && data.response.apps) {
478-
const owners = (data.response.apps as { owner_steamids: string[], exclude_reason: number }[]).filter(app => app.exclude_reason === 0).map((app) => app.owner_steamids).reduce((prev, curr) => {
478+
const apps = (data.response.apps as { owner_steamids: string[], exclude_reason: number }[]).filter(app => app.exclude_reason === 0);
479+
const owners = apps.map((app) => app.owner_steamids).reduce((prev, curr) => {
479480
curr.forEach(id => {
480481
prev.sum[ id ] = (prev.sum[ id ] || 0) + 1;
481482
})
@@ -484,7 +485,7 @@ export async function handleInteraction(interaction: Interaction) {
484485
}
485486
return prev;
486487
}, { sum: {} as Record<string, number>, unique: {} as Record<string, number> });
487-
interaction.reply(`${Object.entries(owners.sum).map(([ id, count ]) => `${steamNameMap[ id ] ?? id}: ${count} (${owners.unique[ id ] ?? 0} unique)`).join("\n")}\nTotal: ${data.response.apps.length} Games\nGames with only one owner: ${Object.values(owners.unique).reduce((a,b) => a+b)}`);
488+
interaction.reply(`${Object.entries(owners.sum).map(([ id, count ]) => `${steamNameMap[ id ] ?? id}: ${count} (${owners.unique[ id ] ?? 0} unique)`).join("\n")}\nTotal: ${apps.length} Games\nGames with only one owner: ${Object.values(owners.unique).reduce((a,b) => a+b)}`);
488489
} else {
489490
interaction.reply("An error occurred while fetching the shared AppIDs.")
490491
}

0 commit comments

Comments
 (0)