Skip to content

feat(ClientApplication): add fetchActivityInstance method#11481

Open
almeidx wants to merge 2 commits intomainfrom
feat/activity-instance
Open

feat(ClientApplication): add fetchActivityInstance method#11481
almeidx wants to merge 2 commits intomainfrom
feat/activity-instance

Conversation

@almeidx
Copy link
Copy Markdown
Member

@almeidx almeidx commented Apr 5, 2026

@almeidx almeidx requested a review from a team as a code owner April 5, 2026 19:05
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
discord-js Skipped Skipped Apr 7, 2026 8:52pm
discord-js-guide Skipped Skipped Apr 7, 2026 8:52pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 884265bd-80ac-4dac-9ac6-2dea1f404e00

📥 Commits

Reviewing files that changed from the base of the PR and between 1f9affd and 7f1ffc8.

📒 Files selected for processing (3)
  • packages/discord.js/src/structures/ClientApplication.js
  • packages/discord.js/src/util/APITypes.js
  • packages/discord.js/typings/index.d.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-03-30T11:04:39.419Z
Learnt from: almeidx
Repo: discordjs/discord.js PR: 11471
File: packages/discord.js/src/util/Util.js:83-86
Timestamp: 2026-03-30T11:04:39.419Z
Learning: For the discord.js and rest packages, follow the existing convention for constructing request URLs: use the `api` base URL and `version` string via raw interpolation (e.g., `${api}/v${version}${route}`) without adding normalization such as trimming trailing slashes on `api` or stripping/adding/remapping a leading `v` on `version`. Do not recommend changing this behavior during code review unless the existing pattern in this repo is intentionally being replaced.

Applied to files:

  • packages/discord.js/src/structures/ClientApplication.js
  • packages/discord.js/src/util/APITypes.js
🔇 Additional comments (6)
packages/discord.js/src/util/APITypes.js (1)

8-11: ActivityLocationKind external type is added cleanly.

This follows the existing APITypes declaration pattern and is ready to merge.

packages/discord.js/src/structures/ClientApplication.js (2)

450-469: Activity instance typedefs are well-structured.

ActivityLocation and ActivityInstanceData are clear and align with the returned object contract.


477-491: fetchActivityInstance mapping looks correct and consistent.

The response transformation is clean, and the guildId normalization on Line 487 keeps the output shape stable.

packages/discord.js/typings/index.d.ts (3)

12-12: No actionable feedback for this import line.

Line 12 is straightforward and doesn’t need a change by itself.


1008-1008: fetchActivityInstance signature looks correct.

Line 1008 cleanly exposes the new API with a strongly typed return contract.


7407-7420: New activity instance typings are well-structured.

Lines 7407-7420 provide a clear and consistent type model for the fetched payload.


📝 Walkthrough

Walkthrough

Added a new fetchActivityInstance(instanceId) async method to ClientApplication that fetches activity instance data from the Discord API, returning an ActivityInstanceData object. Introduced corresponding JSDoc typedefs and TypeScript type definitions for ActivityLocation and ActivityInstanceData structures.

Changes

Cohort / File(s) Summary
Activity Instance Fetch Implementation
packages/discord.js/src/structures/ClientApplication.js
Added fetchActivityInstance(instanceId) async method performing REST GET to fetch activity instance data, with response mapping that normalizes location.guild_id to null when absent.
Type Definitions
packages/discord.js/src/util/APITypes.js, packages/discord.js/typings/index.d.ts
Added JSDoc external type for ActivityLocationKind and TypeScript interfaces for ActivityLocation and ActivityInstanceData with corresponding method signature on ClientApplication.

Sequence Diagram

sequenceDiagram
    actor Client
    participant CA as ClientApplication
    participant API as Discord API
    
    Client->>CA: fetchActivityInstance(instanceId)
    activate CA
    CA->>API: GET /applications/{id}/activity-instances/{instanceId}
    activate API
    API-->>CA: { application_id, instance_id, launch_id, location, users }
    deactivate API
    CA->>CA: Map and normalize response<br/>(location.guild_id ?? null)
    CA-->>Client: ActivityInstanceData
    deactivate CA
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: adding a new fetchActivityInstance method to ClientApplication.
Description check ✅ Passed The description is related to the changeset by referencing the upstream API change that motivated the implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/activity-instance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Apr 6, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js-guide April 7, 2026 20:23 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js April 7, 2026 20:23 Inactive
@almeidx almeidx force-pushed the feat/activity-instance branch from e82bb58 to 9cd710e Compare April 7, 2026 20:24
@vercel vercel bot temporarily deployed to Preview – discord-js-guide April 7, 2026 20:24 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js April 7, 2026 20:24 Inactive
@almeidx almeidx force-pushed the feat/activity-instance branch from 9cd710e to a3f9fbf Compare April 7, 2026 20:52
@vercel vercel bot temporarily deployed to Preview – discord-js-guide April 7, 2026 20:52 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js April 7, 2026 20:52 Inactive
@almeidx almeidx requested a review from vladfrangu April 7, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in Progress

Development

Successfully merging this pull request may close these issues.

3 participants