Repository navigation
feat(music): add /artist and /album commands, fix queue priority - #798
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds two new music commands ( ChangesMusic Commands Enhancement
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 48 minutes and 3 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/bot/src/functions/music/commands/album.spec.ts (1)
178-219: ⚡ Quick winAdd a regression test for non-playlist album search behavior.
Current coverage doesn’t lock the expected behavior when
searchResult.playlistis 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
📒 Files selected for processing (7)
packages/bot/src/functions/music/commands/album.spec.tspackages/bot/src/functions/music/commands/album.tspackages/bot/src/functions/music/commands/artist.spec.tspackages/bot/src/functions/music/commands/artist.tspackages/bot/src/functions/music/commands/play/index.spec.tspackages/bot/src/functions/music/commands/play/index.tssonar-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/artistcommand.The suite exercises both happy-path and key failure paths effectively.
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.
|



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
/albumcommand to queue all tracks from a requested album with optional artist filtering/artistcommand to search for and queue tracks from a specified artist with customizable result limitsImprovements
/playcommand track prioritization behavior for improved consistency across queue management