Skip to content

Commit 1637f3c

Browse files
committed
add steam command
1 parent 661b3eb commit 1637f3c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

interactions.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,35 @@ export async function handleInteraction(interaction: Interaction) {
463463
}
464464
interaction.reply(`Servers of ${member.user.username}:\n${servers.map(server => `<${server}>`).join("\n")}`);
465465
}
466+
467+
if (interaction.commandName === "steam") {
468+
const access_token = Deno.env.get("STEAM_ACCESS_TOKEN");
469+
const family_group_id = Deno.env.get("STEAM_FAMILY_GROUP_ID");
470+
if (!access_token || !family_group_id) {
471+
interaction.reply("Please set the STEAM_ACCESS_TOKEN and STEAM_FAMILY_GROUP_ID environment variables.");
472+
return;
473+
}
474+
fetch(`https://api.steampowered.com/IFamilyGroupsService/GetSharedLibraryApps/v1/?access_token=${access_token}&family_groupid=${family_group_id}`)
475+
.then(res => res.json())
476+
.then(data => {
477+
if (data.response && data.response.apps) {
478+
const owners = (data.reponse.apps as {owner_steamids: string[]}[]).map((app) => app.owner_steamids).reduce((prev,curr) => {
479+
curr.forEach(id => {
480+
prev[id] = (prev[id] || 0) + 1;
481+
})
482+
return prev;
483+
}, {} as Record<string, number>);
484+
interaction.reply(Object.entries(owners).map(([id, count]) => `${id}: ${count}`).join("\n"));
485+
} else {
486+
interaction.reply("An error occurred while fetching the shared AppIDs.")
487+
}
488+
})
489+
.catch(err => {
490+
console.error(err);
491+
interaction.reply("An error occurred while fetching the shared AppIDs.");
492+
});
493+
494+
}
466495
}
467496

468497
const supportRoles = [ "757969277063266407", "815298088184446987", "1120392307087261787" ] // Owner, Dev, Support

main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ client.on("ready", () => {
150150
{
151151
name: "deescalate",
152152
description: "Deescalate a ticket to the previous support level",
153+
},
154+
{
155+
name: "steam",
156+
description: "View Steam Family games"
153157
}
154158
]
155159
});

0 commit comments

Comments
 (0)