Skip to content

fix(bot): playdl auth, version defer, prisma migrate on start - #427

Merged
LucasSantana-Dev merged 4 commits into
mainfrom
fix/init-playdl-defer-version-prisma-migrate
Mar 31, 2026
Merged

LucasSantana-Dev merged 4 commits into
mainfrom
fix/init-playdl-defer-version-prisma-migrate

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Mar 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • LUCKY-26: streamViaSoundCloud was throwing on every track because play-dl SoundCloud auth (getFreeClientID + setToken) was never called at startup — added initPlayDlSoundCloud() that runs sequentially before YoutubeiExtractor registration
  • LUCKY-25: /version used interaction.reply() directly, which races against Discord's 3-second window when reading package.json — replaced with deferReply() + editReply()
  • LUCKY-22: Bot Dockerfile only ran prisma generate (codegen) but never prisma migrate deploy — the live_boards migration was never applied to production DB, causing column channelId does not exist. Added migration to bot CMD.

Test plan

  • CI passes
  • /play <youtube-url> streams audio without skipping at 1s
  • /version responds without "Unknown interaction" in Sentry
  • Bot container starts cleanly with migration applied (check logs for prisma migrate deploy)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed SoundCloud audio streaming errors during playback
    • Fixed /version command timeout issues with improved response handling
    • Fixed bot startup to properly initialize all required database components

@vercel

vercel Bot commented Mar 31, 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 Mar 31, 2026 11:43pm

Request Review

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file bot infra labels Mar 31, 2026
@coderabbitai

coderabbitai Bot commented Mar 31, 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 0 minutes and 28 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 28 seconds.

⌛ 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: 20830aa3-e194-42c2-a53b-4ba925f9893a

📥 Commits

Reviewing files that changed from the base of the PR and between bfefb32 and 3ddabbb.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • Dockerfile
  • packages/bot/package.json
  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
  • packages/bot/src/utils/music/autoplay/stats.spec.ts
  • packages/bot/tests/handlers/player/playerFactory.test.ts
📝 Walkthrough

Walkthrough

This PR addresses three production issues: initializing SoundCloud credentials for play-dl before YouTubei extractor registration, fixing a /version command timeout via deferred Discord replies, and ensuring the live_boards database migration runs at bot container startup.

Changes

Cohort / File(s) Summary
Release & Version
CHANGELOG.md, packages/bot/package.json
Bumps version from 2.6.55 to 2.6.56 and documents three bug fixes: SoundCloud auth initialization, /version command timeout, and missing live_boards migration.
Infrastructure
Dockerfile
Adds npx prisma migrate deploy before bot startup to ensure database migrations are applied before initialization.
Bug Fixes
packages/bot/src/functions/general/commands/version.ts
Replaces direct interaction.reply() with interaction.deferReply() followed by interaction.editReply() to work within Discord's interaction response window and prevent timeouts during file reads.
Extractor Initialization
packages/bot/src/handlers/player/playerFactory.ts
Adds async initialization of play-dl SoundCloud credentials via initPlayDlSoundCloud() before YouTubei extractor registration, with error logging if the client ID fetch fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bot, infra, database, size/m

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 fixes in the changeset: playdl auth initialization, version command deferral, and prisma migration on startup.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/init-playdl-defer-version-prisma-migrate

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.

@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.

🧹 Nitpick comments (1)
packages/bot/src/handlers/player/playerFactory.ts (1)

31-31: Fire-and-forget extractor registration may cause brief unavailability.

The void pattern on lines 29 and 31 discards async promises, returning the player immediately before extractors finish loading. While Discord Player handles missing extractors gracefully with fallbacks (line 88), commands invoked immediately after player creation could fail if extractors aren't yet available.

Consider either awaiting the registration before returning the player, or documenting that Discord Player handles unavailable extractors during the initialization window.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/handlers/player/playerFactory.ts` at line 31, The player is
returned before extractors finish loading because
initPlayDlAndRegisterYoutubei(player) is fired-and-forgotten; change the
initialization to await initPlayDlAndRegisterYoutubei(player) (make the
enclosing function async if needed) so extractors are registered before
returning the player, or alternatively document in the playerFactory function
that Discord Player’s fallback handles temporary extractor unavailability and
callers must wait; reference initPlayDlAndRegisterYoutubei and the player return
path when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bot/src/handlers/player/playerFactory.ts`:
- Line 31: The player is returned before extractors finish loading because
initPlayDlAndRegisterYoutubei(player) is fired-and-forgotten; change the
initialization to await initPlayDlAndRegisterYoutubei(player) (make the
enclosing function async if needed) so extractors are registered before
returning the player, or alternatively document in the playerFactory function
that Discord Player’s fallback handles temporary extractor unavailability and
callers must wait; reference initPlayDlAndRegisterYoutubei and the player return
path when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 036dc34e-d4a0-47d3-a5f1-a93fb7f1f44b

📥 Commits

Reviewing files that changed from the base of the PR and between 6a2b98c and bfefb32.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • Dockerfile
  • packages/bot/package.json
  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
📜 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: SonarCloud Scan
  • GitHub Check: Quality Gates
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{js,jsx,ts,tsx,vue,html}

📄 CodeRabbit inference engine (.cursor/rules/accessibility-openness.mdc)

Provide accessible UI components using semantic HTML and ARIA attributes where necessary

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/dependency-injection.mdc)

**/*.{ts,tsx,js,jsx}: Prefer constructor injection for classes that require dependencies
Avoid global mutable singletons unless necessary
Use explicit interfaces for external dependencies to make testing easier

**/*.{ts,tsx,js,jsx}: Include required references in PRs/code for non-trivial logic: TypeScript (official docs), MDN (JavaScript reference), and official docs for any runtime/framework/libraries used (e.g., Node.js, React) as applicable.
Before assuming behavior of an API, include the doc link and a ≤25-word quote when the change relies on it.

**/*.{ts,tsx,js,jsx}: Prefer named exports for clear usage and easier refactors in TypeScript/JavaScript
Keep import order consistent: external first, then internal modules
Remove dead code and unused imports

**/*.{ts,tsx,js,jsx}: Use PascalCase naming convention for React/UI components
Use camelCase naming convention for variables and functions
Use UPPER_SNAKE_CASE naming convention for constants
Maintain consistent import grouping and ordering within the project, keeping third-party imports separate from local imports
For external data sources (HTTP, database), always validate and sanitize input using type guards or schema validators

**/*.{ts,tsx,js,jsx}: Use Prettier with no semicolons, single quotes, 4-space indent, 80 character width
Files must not exceed 250 lines and this is enforced

Implement TypeScript typecheck and linter in CI quality checks

**/*.{ts,tsx,js,jsx}: Use TypeScript for enhanced type safety
Implement error handling and error logging
Avoid commenting code unless extremely necessary - code should explain itself with descriptive names
Leave NO todos, placeholders or missing pieces in the code
Variables and functions must use camelCase
Constants must use UPPER_SNAKE_CASE
Use arrow functions for methods and computed properties
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
Maintain consistent import grouping/order: external imports first, then...

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{js,jsx,ts,tsx}: Never throw strings. Throw Error (or typed subclasses) with descriptive messages
Include causal error as cause when available for better debugging
Define clear, stable error codes (e.g., ERR_AUTH_EXPIRED, ERR_NETWORK_TIMEOUT)
Provide optional metadata (e.g., details, retryable, status, correlationId) in error objects
Use domain error classes per area (e.g., AuthenticationError, ValidationError, NetworkError)
Log errors with structure (message, code, stack, cause, correlationId, user context where appropriate)
Mark retryable vs nonRetryable errors where helpful for operations
Set timeouts and handle aborts/cancellations; avoid dangling requests in API/network code
Implement backoff for transient failures; avoid infinite retries
Map HTTP status → domain errors; 4xx vs 5xx behave differently (e.g., retry for 5xx/network)

**/*.{js,jsx,ts,tsx}: Use functional components with hooks in React/React Native. Avoid class components.
Keep components focused on a single responsibility; extract complex logic into custom hooks.
Keep state local when possible. Use Context/Zustand/Redux only when necessary for state management.
If props or state traverse more than 3 levels, consider using context or a feature-scoped store instead of prop drilling.
Use performance optimization techniques: React.memo, useMemo, useCallback, Suspense (web), and virtualization for long lists; avoid unnecessary re-renders.
Web accessibility: use semantic HTML, labels, focus management, keyboard navigation, and aria-* attributes as needed.
React Native accessibility: use accessibility props (accessible, accessibilityLabel), proper roles and labels.
Identify and extract repetitive UI components proactively to components/ with clear props and minimal coupling.
Web styles: prefer co-located styles or design system tokens; avoid global style leakage.
React Native styles: prefer StyleSheet.create, design tokens, and theme providers; avoid in...

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

Introduce interfaces at module boundaries to enable testing and substitutions

**/*.{ts,tsx}: Avoid using any type in TypeScript. If unavoidable, use unknown with type guards and justify with a code comment
Prefer interface for defining public object shapes in TypeScript, use type for unions and utility types
Use TypeScript utility types such as Partial, Pick, Omit, Readonly, and Record when appropriate
Use I{Name} naming convention for interfaces in TypeScript
Use T{Name} naming convention for type aliases and utility types in TypeScript

**/*.{ts,tsx}: Functions must be less than 50 lines with cyclomatic complexity less than 10
Do not use any types - ESLint enforces this at error level

**/*.{ts,tsx}: Prefer types over interfaces for most cases
Don't ever use any - type safety always
Avoid enums; use const objects instead
For complex types, create a separate file to declare them and import them
Avoid using any type; if unavoidable, use unknown with type guards and justify with code comment
Prefer interface for public API shapes; use type for unions and utility types
Use TypeScript utility types (Partial, Pick, Omit, Readonly, Record)

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
packages/bot/src/functions/**/commands/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Discord bot commands must be structured in packages/bot/src/functions/<category>/commands/<name>.ts with handlers in <category>/handlers/

Files:

  • packages/bot/src/functions/general/commands/version.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/documentation.mdc)

**/*.{js,ts,tsx,jsx}: Minimize comments in code; explain the 'why' when non-obvious, let code express the 'what' through clear naming
Document trade-offs briefly when deviating from ideal patterns

**/*.{js,ts,tsx,jsx}: Store secrets, ports, and hosts in environment variables (.env, .env.example) and never hardcode them
Avoid redundant or decorative AI comments; code should be self-explanatory and only commented when logic is non-obvious; prefer refactoring over lengthy comments

Never hardcode secrets, IPs, or ports; use .env and docs/ for required configuration variables

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
packages/bot/src/functions/*/commands/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/src/functions/*/commands/**/*.{ts,tsx}: Command model must include data (slash builder), execute, and category properties exported from packages/bot/src/models/Command.ts
Use @discordjs/builders for building the data (SlashCommandBuilder) in command definitions
Command execute function must receive { interaction, client } parameters from CommandExecuteParams type
Use interactionReply and createUserFriendlyError utilities from @lucky/shared/general utils for command replies and error handling
Use existing validators from packages/bot/src/utils/command/ for voice channel, queue, and guild validations in commands

Files:

  • packages/bot/src/functions/general/commands/version.ts
packages/bot/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/**/*.{ts,tsx}: Use useMainPlayer() from discord-player to access the player instance; do not instantiate player directly
Do not duplicate queue or player state outside Discord Player; use shared services from @lucky/shared for persistent data like track history and session information
Use errorLog and debugLog from @lucky/shared/utils for logging throughout the bot package
Use embed and reply utilities from @lucky/shared for consistent message formatting and error sanitization across the bot
Use services from @lucky/shared (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
packages/bot/**

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

The bot package depends on shared and contains Discord bot commands and player handlers using Discord.js and Discord Player

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/package.json
  • packages/bot/src/handlers/player/playerFactory.ts
**/*.{js,mjs,ts,mts}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Use Node.js version ≥22 with ESM (ECMAScript modules) only; no CommonJS

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
packages/bot/src/functions/{general,music,download}/commands/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

packages/bot/src/functions/{general,music,download}/commands/**/*.ts: Apply .cursor/rules/lucky-discord-bot.mdc rules for Discord bot commands and player implementation
Use .cursor/skills/discord-commands/SKILL.md for implementing slash commands

Files:

  • packages/bot/src/functions/general/commands/version.ts
packages/bot/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use @lucky/shared for database, Redis, logging, and embed utilities instead of implementing them locally

Files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/src/handlers/player/playerFactory.ts
{LICENSE,COPYING,COPYING.md,LICENSE.md,license.txt,**/package.json,**/requirements.txt,**/Cargo.toml,**/pom.xml,**/composer.json}

📄 CodeRabbit inference engine (.cursor/rules/accessibility-openness.mdc)

Respect OSS licenses for third-party code and declare license in repo

Files:

  • packages/bot/package.json
packages/bot/src/handlers/player/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

Track handling, errors, and lifecycle must be managed through dedicated handlers in packages/bot/src/handlers/player/ (trackHandlers, errorHandlers, lifecycleHandlers)

Files:

  • packages/bot/src/handlers/player/playerFactory.ts
{CHANGELOG.md,README.md}

📄 CodeRabbit inference engine (.cursor/rules/agent-rules.mdc)

ALWAYS update CHANGELOG.md and README.md as changes are made.

Files:

  • CHANGELOG.md
CHANGELOG.md

📄 CodeRabbit inference engine (.cursor/rules/templates-examples.mdc)

CHANGELOG.md must be updated with all changes in pull requests

Always update CHANGELOG.md with all code changes

Update CHANGELOG.md with all changes, include breaking changes documentation, and reference issues and PRs

Files:

  • CHANGELOG.md
{CHANGELOG.md,docs/**}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Update CHANGELOG.md and relevant docs/ files when behavior or setup changes

Files:

  • CHANGELOG.md
🧠 Learnings (23)
📓 Common learnings
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/{general,music,download}/commands/**/*.ts : Apply `.cursor/rules/lucky-discord-bot.mdc` rules for Discord bot commands and player implementation
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use services from `lucky/shared` (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Do not duplicate queue or player state outside Discord Player; use shared services from `lucky/shared` for persistent data like track history and session information
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working with Prisma schema, migrations, DB/Redis in shared packages, use the `prisma-redis-lucky` skill
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/**/*.ts : Use `lucky/shared` for database, Redis, logging, and embed utilities instead of implementing them locally
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use embed and reply utilities from `lucky/shared` for consistent message formatting and error sanitization across the bot
📚 Learning: 2026-03-09T20:21:15.595Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-shared.mdc:0-0
Timestamp: 2026-03-09T20:21:15.595Z
Learning: Applies to packages/shared/**/*.ts : Use the single Prisma client located at `packages/shared/src/utils/database/prismaClient.ts`; maintain schema in repo root at `prisma/schema.prisma`; run migrations from root using `npm run db:migrate`

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When making Prisma schema changes or migrations, use the `database-migration` ecosystem skill

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to package.json : Use `npm run dev:bot`, `npm run dev:backend`, and `npm run dev:frontend` for development, and `npm run db:*` commands for database operations

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: Build process: use `npm run build` for packages (shared → bot → backend) and `npm run build:frontend` for frontend; development with `npm run dev:bot`, `npm run dev:backend`, `npm run dev:frontend`

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:46.291Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Use `npm run db:deploy` command from repo root for deploying migrations

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:46.291Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Use `npm run db:generate` command from repo root for Prisma code generation

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use services from `lucky/shared` (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to package.json : Use `npm run build` for shared → bot → backend build order; use `npm run build:frontend` separately for frontend

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to src/**/*.{ts,tsx,js,jsx} : Implement health/readiness endpoints in backend services

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/src/functions/*/commands/**/*.{ts,tsx} : Use `interactionReply` and `createUserFriendlyError` utilities from `lucky/shared/general` utils for command replies and error handling

Applied to files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/package.json
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/src/functions/*/commands/**/*.{ts,tsx} : Command `execute` function must receive `{ interaction, client }` parameters from `CommandExecuteParams` type

Applied to files:

  • packages/bot/src/functions/general/commands/version.ts
📚 Learning: 2026-03-09T20:20:23.892Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-09T20:20:23.892Z
Learning: Applies to packages/bot/src/functions/**/commands/*.ts : Discord bot commands must be structured in `packages/bot/src/functions/<category>/commands/<name>.ts` with handlers in `<category>/handlers/`

Applied to files:

  • packages/bot/src/functions/general/commands/version.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/src/functions/*/commands/**/*.{ts,tsx} : Use `discordjs/builders` for building the `data` (SlashCommandBuilder) in command definitions

Applied to files:

  • packages/bot/src/functions/general/commands/version.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use embed and reply utilities from `lucky/shared` for consistent message formatting and error sanitization across the bot

Applied to files:

  • packages/bot/src/functions/general/commands/version.ts
  • packages/bot/package.json
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/**/*.ts : Use `lucky/shared` for database, Redis, logging, and embed utilities instead of implementing them locally

Applied to files:

  • packages/bot/package.json
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use `errorLog` and `debugLog` from `lucky/shared/utils` for logging throughout the bot package

Applied to files:

  • packages/bot/package.json
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/{general,music,download}/commands/**/*.ts : Apply `.cursor/rules/lucky-discord-bot.mdc` rules for Discord bot commands and player implementation

Applied to files:

  • packages/bot/package.json
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to packages/bot/** : The `bot` package depends on `shared` and contains Discord bot commands and player handlers using Discord.js and Discord Player

Applied to files:

  • packages/bot/package.json
  • packages/bot/src/handlers/player/playerFactory.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Do not duplicate queue or player state outside Discord Player; use shared services from `lucky/shared` for persistent data like track history and session information

Applied to files:

  • packages/bot/package.json
  • packages/bot/src/handlers/player/playerFactory.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use `useMainPlayer()` from `discord-player` to access the player instance; do not instantiate player directly

Applied to files:

  • packages/bot/src/handlers/player/playerFactory.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/src/handlers/player/**/*.{ts,tsx} : Track handling, errors, and lifecycle must be managed through dedicated handlers in `packages/bot/src/handlers/player/` (trackHandlers, errorHandlers, lifecycleHandlers)

Applied to files:

  • packages/bot/src/handlers/player/playerFactory.ts
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/music/**/*.ts : Use existing voice/queue/guild validators before manipulating player or queue state

Applied to files:

  • packages/bot/src/handlers/player/playerFactory.ts
🔇 Additional comments (6)
Dockerfile (1)

102-102: Migration-on-startup approach is sound.

Running prisma migrate deploy before the bot process ensures the schema is up-to-date before initialization. The && chaining provides fail-fast behavior if migrations fail.

One consideration: if a migration fails, the container will exit without detailed logs visible in typical orchestration dashboards. The current approach is acceptable, but you may want to add migration output logging or a wrapper script for better observability in production incidents.

packages/bot/src/functions/general/commands/version.ts (1)

31-40: LGTM — Defer pattern correctly addresses interaction timeout.

Using deferReply({ ephemeral: true }) followed by editReply() prevents Discord's 3-second interaction timeout from triggering while readVersion() performs file I/O. The ephemeral flag placement is correct for Discord.js v14.

packages/bot/src/handlers/player/playerFactory.ts (2)

39-56: SoundCloud initialization with graceful fallback is well-designed.

The sequential flow (init SoundCloud → register YouTubei) addresses the PR objective. The try-catch with warnLog ensures the bot continues even if SoundCloud auth fails, while still logging actionable diagnostics.


93-134: SoundCloud stream bridge implementation looks correct.

The matching logic with title normalization and duration tolerance (±15s) is reasonable. Error messages are descriptive for debugging. The function properly returns the stream from playdl.stream().

One edge case: if track.author is empty or undefined, the query becomes just the title, which may produce less accurate results. This is acceptable given the fallback nature of this bridge.

packages/bot/package.json (1)

3-3: LGTM — Version bump aligns with changelog.

CHANGELOG.md (1)

10-17: LGTM — Changelog entry is complete and well-documented.

All three fixes from the PR objectives are documented with clear descriptions and issue references. The format follows Keep a Changelog conventions.

- deferReply()+editReply() in /version to avoid 3s timeout (LUCKY-25)
- prisma migrate deploy in bot CMD for live_boards column (LUCKY-22)
- call getFreeClientID()+setToken() before youtubei extractor so
  the soundcloud stream bridge actually works (lucky-26)
- bump version to 2.6.56, update changelog
getFreeClientID() makes a real network call; mock it so the
async registration polling (500ms) completes in time
using 1ms margin fails when getAutoplayStats() calls Date.now()
independently -- use 1-day margin instead
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@LucasSantana-Dev
LucasSantana-Dev merged commit a1c65f9 into main Mar 31, 2026
11 of 12 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/init-playdl-defer-version-prisma-migrate branch March 31, 2026 23:48

This branch was successfully deployed

1 active deployment
Preview — 3ddabbb8 Deployed Mar 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot dependencies Pull requests that update a dependency file infra size/m size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant