Skip to content

feat(music): add /artist and /album commands, fix queue priority - #798

Merged
LucasSantana-Dev merged 14 commits into
mainfrom
feature/artist-album-commands
May 4, 2026
Merged

LucasSantana-Dev merged 14 commits into
mainfrom
feature/artist-album-commands

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented May 3, 2026 •

Copy link
Copy Markdown
Owner

Add /artist command (queue top tracks by artist, 1-20 via Spotify), /album command (queue full album by URL or search), and fix /play priority bug where tracks already in autoplay buffer were not being promoted to front of user queue.

Summary by CodeRabbit

  • New Features

    • Added /album command to queue all tracks from a requested album with optional artist filtering
    • Added /artist command to search for and queue tracks from a specified artist with customizable result limits
  • Improvements

    • Enhanced /play command track prioritization behavior for improved consistency across queue management

@vercel

vercel Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment May 4, 2026 0:23am

Request Review

@coderabbitai

coderabbitai Bot commented May 3, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 3 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af6f66da-b5c2-494e-85ea-76e1c01f85b5

📥 Commits

Reviewing files that changed from the base of the PR and between abf6951 and 8d1e909.

📒 Files selected for processing (2)
  • packages/bot/src/functions/music/commands/album.spec.ts
  • packages/bot/src/functions/music/commands/album.ts
📝 Walkthrough

Walkthrough

Adds two new music commands (/album and /artist) that queue tracks from Spotify albums and artists respectively, with comprehensive test coverage. Also simplifies the /play command to unconditionally call track prioritization, removing the duplicate-queue check. Updates Sonar exclusions for the new files.

Changes

Music Commands Enhancement

Layer / File(s) Summary
New Album Command
packages/bot/src/functions/music/commands/album.ts
Adds /album command that queues all tracks from a requested album, validating guild/voice/DJ role membership, detecting Spotify album URLs for engine selection, playing the first track, enqueuing the rest, and prioritizing the user's entry.
New Artist Command
packages/bot/src/functions/music/commands/artist.ts
Adds /artist command that searches Spotify for tracks by artist, queues up to a configurable limit (default 10, max 20), filters results by author name, plays the first track, enqueues the rest, and prioritizes the user's track.
Priority Behavior Simplification
packages/bot/src/functions/music/commands/play/index.ts
Removes the isTrackAlreadyQueued check and unconditionally calls moveUserTrackToPriority when queueing non-playlist tracks, aligning priority handling across all queue commands.
Test Coverage
packages/bot/src/functions/music/commands/album.spec.ts, packages/bot/src/functions/music/commands/artist.spec.ts, packages/bot/src/functions/music/commands/play/index.spec.ts
Adds comprehensive test suites for album and artist commands covering guild validation, voice/DJ role checks, search failures, successful queuing, and error handling. Updates play command tests to verify unconditional priority calls in autoplay and duplicate-track scenarios.
Configuration Update
sonar-project.properties
Updates code duplication exclusions to include new artist.ts, album.ts, and play/spotifyHandler.ts, removing the previous spotify.ts exclusion.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes all three main changes in the PR: addition of /artist command, addition of /album command, and the queue priority bug fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/artist-album-commands

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
Review rate limit: 0/1 reviews remaining, refill in 48 minutes and 3 seconds.

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

coderabbitai[bot]
coderabbitai Bot previously requested changes May 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/bot/src/functions/music/commands/album.spec.ts (1)

178-219: ⚡ Quick win

Add a regression test for non-playlist album search behavior.

Current coverage doesn’t lock the expected behavior when searchResult.playlist is absent but multiple tracks are returned.

🧪 Suggested test addition
+    it('returns an album-specific error when search does not resolve to a playlist', async () => {
+        const interaction = createInteraction('guild-1', 'OK Computer')
+        const client = createClient({
+            playlist: null,
+            tracks: [
+                { url: 'url-1', requestedBy: null },
+                { url: 'url-2', requestedBy: null },
+            ],
+        })
+
+        await albumCommand.execute({ client, interaction } as any)
+
+        expect(interactionReplyMock).toHaveBeenCalledWith(
+            expect.objectContaining({
+                content: expect.objectContaining({
+                    embeds: expect.arrayContaining([
+                        expect.objectContaining({ type: 'error' }),
+                    ]),
+                }),
+            }),
+        )
+    })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/album.spec.ts` around lines 178 -
219, Add a regression test to cover the case where client.player.search returns
multiple tracks but no searchResult.playlist: create an interaction and client
via createClient, mock client.player.search to resolve to an object like {
tracks: [{url:'u1'},{url:'u2'}] } (no playlist property), have
resolveGuildQueueMock return a queue with addTrack mocked, call
albumCommand.execute({ client, interaction }), and assert queue.addTrack was
called for the non-priority tracks, moveUserTrackToPriorityMock was called for
the requesting track, and createSuccessEmbedMock was called with the expected
album/title and track count; reference albumCommand.execute,
client.player.search, resolveGuildQueueMock, createClient,
createSuccessEmbedMock, moveUserTrackToPriorityMock, and queue.addTrack to
locate the code to modify.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bot/src/functions/music/commands/album.ts`:
- Around line 22-24: The current isSpotifyAlbumUrl uses a narrow regex and
misses locale-style or varied Spotify album URLs; update isSpotifyAlbumUrl to
parse the input as a URL (try new URL(query), and if that fails attempt to
prepend "https://" and parse again), then validate that the hostname endsWith
"spotify.com" and that the pathname contains the path segment "album" (e.g.,
pathname.split('/').includes('album')) so locale prefixes like
"/intl-de/album/..." are accepted; wrap parsing in try/catch and return false on
errors.
- Around line 103-106: The album command currently collapses non-playlist search
results to a single track by using searchResult.tracks.slice(0, 1); update the
logic in packages/bot/src/functions/music/commands/album.ts so tracks is
assigned the full searchResult.tracks (i.e., const tracks = searchResult.tracks)
and remove the playlist conditional; also ensure any downstream
queueing/response code that assumed a single track (references to tracks being a
single item or using .shift()/.pop()) iterates over the full tracks array and
builds the success message to reflect the actual number of queued tracks.

---

Nitpick comments:
In `@packages/bot/src/functions/music/commands/album.spec.ts`:
- Around line 178-219: Add a regression test to cover the case where
client.player.search returns multiple tracks but no searchResult.playlist:
create an interaction and client via createClient, mock client.player.search to
resolve to an object like { tracks: [{url:'u1'},{url:'u2'}] } (no playlist
property), have resolveGuildQueueMock return a queue with addTrack mocked, call
albumCommand.execute({ client, interaction }), and assert queue.addTrack was
called for the non-priority tracks, moveUserTrackToPriorityMock was called for
the requesting track, and createSuccessEmbedMock was called with the expected
album/title and track count; reference albumCommand.execute,
client.player.search, resolveGuildQueueMock, createClient,
createSuccessEmbedMock, moveUserTrackToPriorityMock, and queue.addTrack to
locate the code to modify.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 132378c7-694f-4ffb-abb4-0ea766a7d197

📥 Commits

Reviewing files that changed from the base of the PR and between 72ee59e and abf6951.

📒 Files selected for processing (7)
  • packages/bot/src/functions/music/commands/album.spec.ts
  • packages/bot/src/functions/music/commands/album.ts
  • packages/bot/src/functions/music/commands/artist.spec.ts
  • packages/bot/src/functions/music/commands/artist.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • sonar-project.properties
📜 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). (2)
  • GitHub Check: Quality Gates
  • GitHub Check: SonarCloud Scan
🔇 Additional comments (5)
sonar-project.properties (1)

15-15: CPD exclusion update looks consistent with this PR scope.

No blocking concerns in this config change.

packages/bot/src/functions/music/commands/artist.ts (1)

46-203: Solid command flow and failure handling.

Validation, interaction lifecycle handling, queueing, and sanitized error response paths are well-structured.

packages/bot/src/functions/music/commands/play/index.ts (1)

205-207: Unconditional prioritization call is safe here.

Given the helper’s guard behavior, this simplification improves consistency without introducing regressions.

packages/bot/src/functions/music/commands/play/index.spec.ts (1)

473-579: Test updates correctly reflect the new priority semantics.

The revised assertions match the command’s unconditional prioritization behavior.

packages/bot/src/functions/music/commands/artist.spec.ts (1)

104-230: Good branch coverage for the new /artist command.

The suite exercises both happy-path and key failure paths effectively.

Comment thread packages/bot/src/functions/music/commands/album.ts
Comment thread packages/bot/src/functions/music/commands/album.ts Outdated
@LucasSantana-Dev
LucasSantana-Dev dismissed coderabbitai[bot]’s stale review May 4, 2026 00:21

All actionable items addressed: isSpotifyAlbumUrl updated to use URL parsing (landed via CodeRabbit's own commit), and album spec fixed with correct playlist-required behavior test.

@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit f7eccd2 into main May 4, 2026
12 checks passed

This branch was successfully deployed

1 active deployment
Preview — 8d1e9090 Deployed May 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot enhancement New feature or request size/xl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant