Skip to content

Feature/slash commands v1#40

Open
arif-banai wants to merge 33 commits into
masterfrom
feature/slash-commands-v1
Open

Feature/slash commands v1#40
arif-banai wants to merge 33 commits into
masterfrom
feature/slash-commands-v1

Conversation

@arif-banai

Copy link
Copy Markdown
Owner

Refactor to decouple command behavior from the message-based interface.

- introduced service-layer abstraction in `PlayerService`.
- Introduced slash command `NowPlayingSlashCmd` for better interactivity.
- Migrated existing command architecture into versioned packages (`v1`, `v2`).
- Updated `pom.xml` to use version `0.5.2-beta-nowplayingcmd`.
- Added support for button interactions in `Listener`.
…quotes if detected, improve skip/now-playing Button functionality
- Restart track if playing for more than 5 seconds.
- Prevent duplicate tracks in queue.
- Clear `previousTracks` on stop.
- Ensure replacement tracks don't trigger queue logic.
- Add Mockito and JaCoCo dependencies for testing and coverage reporting.
- Configure JaCoCo Maven plugin for test coverage generation.
- Improve XML formatting for better readability.
- Introduced `maxHistorySize` in `BotConfig` for configurable history limit.
- Added `HistoryQueue` to manage previously played tracks.
- Implemented rewind functionality with optional queue adjustments.
- Extended queue operations with methods like `addToHistory`, `clearAll`, and `removeLastPlayed`.
- Removed unused `progressBar` method from `FormatUtil`.
- Replace previous track handling with a new `HistoryQueue` implementation for better history tracking.
- Update `AudioHandler` to utilize queue history instead of a separate list for previous tracks.
- Enhance rewind functionality to check for available history and respond accordingly.
- Set default maximum history size to 50 tracks.
- Added tests for `AloneInVoiceHandler`, `AudioHandler`, `FormatUtil`, `HistoryQueue`, `LinearQueue`, `PlayerService`, and `Settings`.
- Improved test coverage with edge cases and validation for core functionalities.
- Centralize logic for previous, shuffle, repeat, volume adjustment, skip, stop, and pause actions into `PlayerService`.
- Improve code reusability and maintainability by introducing `OutputAdapter` for unified response handling.
- Introduce support for `editNowPlaying` and `editNoMusic` methods to streamline message updates.
- Change logger variable to static in AudioHandler
- Remove hardcoded maxSize for HistoryQueue
- Add maxhistorysize to reference.conf (default config)
- Introduced the Maven Compiler Plugin (version 3.14.1) to set Java source and target versions to 17.
- Extract property checks in Prompt class into a separate method, `isPropertyEnabled`, for better maintainability. This makes sure if -Dnogui is provided, it will not attempt to init the gui.
- Bump project version to 0.6.2-slash-commands in pom.xml.
- Replace JUnit 4 `@Before` annotation with JUnit 5 `@BeforeEach` in TestBase class.
- Remove deprecated Mockito dependency from pom.xml.
- Move some tests around
- Introduced `SlashCommandRegistry` to handle the registration of slash commands with Discord, ensuring commands are only registered when they have changed.
- Refactored `Listener` to register slash commands upon startup
- Replaced deprecated button handling in `PlayerService` with JDA's native button components for improved interaction.
- Added unit tests for `SlashCommandRegistry` to verify command registration logic and hash management.
- Introduced `MusicCommandValidator` to centralize validation logic for music commands, ensuring proper checks for text and slash commands.
- Refactored `MusicCommand`, `PlayCmd`, and `MusicSlashCommand` to utilize the new validator, improving code maintainability and reducing duplication.
- Added reusable output adapters for slash command responses to streamline message handling and error reporting.
- Enhanced `PlaySlashCmd` with improved input handling and autocomplete functionality for better user experience.
- Replaced `PlayerService` with `MusicService` to centralize music operations, enhancing maintainability and clarity.
- Introduced `SearchService` for handling search-related operations, improving separation of concerns.
- Updated command classes to utilize the new `MusicService` and `SearchService`, ensuring consistent handling of music commands across text and slash commands.
- Added reusable output adapters for better response management in both command types.
- Removed deprecated `PlayerService` and refactored related tests to align with the new service structure.
- Updated README to note min Java version required - Java 25
- Introduced new slash command classes for admin functionalities, including `PrefixSlashCmd`, `QueuetypeSlashCmd`, and others, enhancing command management.
- Refactored existing commands to utilize the new `MusicService` for improved functionality and consistency.
- Added architectural documentation for better understanding of the system structure.
- Enhanced the `run_jmusicbot.sh` script with JVM options for better compatibility with Java 22+.
…ion dependencies

- Specified that glibc version must be 2.38 or higher for proper functionality.
- Revised instructions for running the bot directly and clarified native library installation steps.
- Enhanced documentation for Docker usage and configuration persistence.
…r link

- Corrected the link to the lavaplayer documentation for supported sources and formats.
@arif-banai arif-banai mentioned this pull request Jan 27, 2026
@codecov

codecov Bot commented Jan 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.73905% with 1361 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.42%. Comparing base (b1963c1) to head (930af27).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...va/com/jagrosh/jmusicbot/service/MusicService.java 54.86% 177 Missing and 27 partials ⚠️
...osh/jmusicbot/service/AudioLoadResultHandlers.java 10.60% 118 Missing ⚠️
...m/jagrosh/jmusicbot/commands/v1/music/PlayCmd.java 0.00% 57 Missing ⚠️
...a/com/jagrosh/jmusicbot/service/SearchService.java 8.62% 53 Missing ⚠️
.../jagrosh/jmusicbot/commands/v1/music/QueueCmd.java 0.00% 49 Missing ⚠️
.../com/jagrosh/jmusicbot/utils/MessageFormatter.java 0.00% 45 Missing ⚠️
...rosh/jmusicbot/commands/v1/TextOutputAdapters.java 0.00% 35 Missing ⚠️
...jagrosh/jmusicbot/commands/v1/dj/MoveTrackCmd.java 0.00% 31 Missing ⚠️
...sh/jmusicbot/commands/v2/music/SearchSlashCmd.java 65.16% 30 Missing and 1 partial ⚠️
...om/jagrosh/jmusicbot/commands/v1/MusicCommand.java 0.00% 29 Missing ⚠️
... and 57 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master      #40       +/-   ##
===========================================
+ Coverage   23.83%   35.42%   +11.58%     
===========================================
  Files          87      124       +37     
  Lines        3486     4980     +1494     
  Branches      483      629      +146     
===========================================
+ Hits          831     1764      +933     
- Misses       2600     3100      +500     
- Partials       55      116       +61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arif-banai arif-banai linked an issue Jan 27, 2026 that may be closed by this pull request
@arif-banai arif-banai self-assigned this Jan 27, 2026
- Introduced `SlashCommandTestFixture` to provide common mocks and setup for slash command tests, enhancing test maintainability.
- Added `TestMusicSlashCommand` for testing validation logic in music commands, exposing protected methods for easier verification.
- Created `ValidationScenarioBuilder` to streamline the setup of various validation scenarios for music commands.
- Implemented unit tests for `MusicSlashCommand`, `PlaySlashCmd`, `QueueSlashCmd`, and `SearchSlashCmd`, ensuring robust validation and functionality of slash commands.
- Enhanced `SlashOutputAdapters` for improved response management in slash command interactions.
… retrieval

- Updated OkHttpClient in OtherUtil to include connection, read, and write timeouts for better network handling.
- Enhanced unit tests in OtherUtilTest to cover scenarios for empty API responses and API call failures, ensuring robustness in version retrieval logic.
- Introduced `TestConstants` for shared constants across test fixtures, ensuring consistency in test setups.
- Created `AudioTestFixture` for common mocks and setup for audio component tests, enhancing test maintainability.
- Developed `ListenerTestFixture` for consistent mock setup in listener tests, streamlining test configuration.
- Added `ServiceTestFixture` for comprehensive service-level testing, providing a robust foundation for testing `MusicService` and related classes.
- Implemented `MusicServiceScenarioBuilder` and `QueueStateBuilder` for constructing test scenarios and queue states, improving test clarity and reusability.
- Introduced `OutputAdapterSpy` for capturing and verifying output messages in tests, enhancing validation of service responses.
- Added `PermissionStateBuilder` for constructing permission-related test scenarios, facilitating testing of user permissions in various contexts.
- Enhanced unit tests for `MusicService`, `AudioHandler`, and `NowPlayingHandler`, ensuring thorough coverage of functionality and edge cases.
@arif-banai arif-banai marked this pull request as ready for review January 27, 2026 10:51
- Updated various components, including `Bot`, `BotConfig`, and `DiscordService`, to utilize the  `UserInteraction` interface for alerting users.
- Replaced previous `Prompt` usage with `UserInteraction.Level`
- Enhanced error handling in `Listener` to notify users of missing Discord intents during session disconnects.
- Updated tests to reflect changes in user interaction handling, ensuring robust coverage of alert mechanisms.
…e for improved build process

- Introduced .gitattributes to enforce consistent line endings across different file types.
- Updated Dockerfile to use a specific Maven version and Alpine base image for the builder stage.
- Enhanced the Dockerfile to create a custom minimal JRE using jlink, optimizing the runtime image.
- Improved user and application directory creation in a single layer for better efficiency.
- Removed the `--update-snapshots` flag from Maven commands in `build-and-test.yml`, `make-release.yml`, and `publish-preview-image.yml` workflows to streamline the build process.
- Revised the list of Java modules included in the minimal JRE created by jlink, adding necessary modules for improved functionality and compatibility.
- Enhanced comments to clarify the rationale behind module selection, ensuring better understanding for future modifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Slash Commands

1 participant