Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
Merged
3 changes: 3 additions & 0 deletions hydrogen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

- Create the shared behavior to share logic between components and commands.
- Create the loop command.
- Implement autoplay loop mode using YouTube Mix.
- Implement duplicate detection.
- Implement helper functions to get the YouTube video ID from a Track.
- Implement `PlayerManager::shuffle` method.
- Implement the shuffle component.

Expand Down
3 changes: 3 additions & 0 deletions hydrogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ the [dev/README.md](https://github.com/nashiradeer/hydrogen-bot/blob/main/hydrog

## Using

**Warning:** YouTube Source is not optional, it is required because the autoplay feature uses it to get the next song
from a YouTube mix.

Hydrogen is available on
our [GitHub Container Registry](https://github.com/nashiradeer/hydrogen-bot/pkgs/container/hydrogen-bot), you can use it
by running
Expand Down
2 changes: 1 addition & 1 deletion hydrogen/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- [ ] Create the about command.
- [ ] Create the donate command.
- [ ] Create a command to set Music Player language.
- [ ] Implement auto-play loop mode.
- [x] Implement auto-play loop mode.

## 0.0.1-alpha.15

Expand Down
11 changes: 7 additions & 4 deletions hydrogen/dev/_application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ plugins:
allowDirectPlaylistIds: true
clients:
- MUSIC
- ANDROID_VR
- WEB
- WEBEMBEDDED
- TVHTML5EMBEDDED
- TV

Expand All @@ -39,14 +41,15 @@ plugins:
localFiles: false
deezer:
masterDecryptionKey: # Paste your master decryption key here
arl: # Paste your ARL token here
formats: [ "MP3_128", "MP3_64" ]

lavalink:
plugins:
- dependency: "dev.lavalink.youtube:youtube-plugin:1.12.0"
repository: "https://maven.lavalink.dev/releases"
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.3.0"
repository: "https://maven.lavalink.dev/releases"
- dependency: "dev.lavalink.youtube:youtube-plugin:1.13.2"
snapshot: false
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.6.0"
snapshot: false

server:
password: # Paste your Lavalink password here
Expand Down
14 changes: 11 additions & 3 deletions hydrogen/src/commands/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
use beef::lean::Cow;
use serenity::all::{CommandOptionType, CreateCommandOption};
use serenity::{all::CommandInteraction, builder::CreateCommand, client::Context};
use tracing::{event, Level};
use tracing::{Level, event};

use crate::i18n::{serenity_command_option_description, serenity_command_option_name, t, t_all};
use crate::music::PlayerTemplate;
use crate::{
LOADED_COMMANDS, PLAYER_MANAGER,
i18n::{serenity_command_description, serenity_command_name, t_vars},
utils, LOADED_COMMANDS, PLAYER_MANAGER,
utils,
};

/// Executes the `/join` command.
Expand Down Expand Up @@ -40,6 +41,7 @@ pub async fn execute<'a>(context: &Context, interaction: &CommandInteraction) ->
Some("queue") => PlayerTemplate::Queue,
Some("manual") => PlayerTemplate::Manual,
Some("rpg") => PlayerTemplate::Rpg,
Some("autoplay") => PlayerTemplate::Autoplay,
_ => PlayerTemplate::Default,
};

Expand Down Expand Up @@ -83,6 +85,7 @@ pub async fn execute<'a>(context: &Context, interaction: &CommandInteraction) ->
PlayerTemplate::Queue => t(&interaction.locale, "join.template_queue"),
PlayerTemplate::Manual => t(&interaction.locale, "join.template_manual"),
PlayerTemplate::Rpg => t(&interaction.locale, "join.template_rpg"),
PlayerTemplate::Autoplay => t(&interaction.locale, "join.template_autoplay"),
};

let play_command = match LOADED_COMMANDS.get().and_then(|v| v.get("play")) {
Expand Down Expand Up @@ -117,7 +120,12 @@ pub fn create_command() -> CreateCommand {
.add_string_choice_localized("Music", "music", t_all("join.template_music"))
.add_string_choice_localized("Queue", "queue", t_all("join.template_queue"))
.add_string_choice_localized("Manual", "manual", t_all("join.template_manual"))
.add_string_choice_localized("RPG", "rpg", t_all("join.template_rpg"));
.add_string_choice_localized("RPG", "rpg", t_all("join.template_rpg"))
.add_string_choice_localized(
"Autoplay",
"autoplay",
t_all("join.template_autoplay"),
);

option = serenity_command_option_name("join.template_name", option);
option = serenity_command_option_description("join.template_description", option);
Expand Down
19 changes: 11 additions & 8 deletions hydrogen/src/commands/loop_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub async fn execute<'a>(context: &Context, interaction: &CommandInteraction) ->
Some("single") => LoopMode::Single,
Some("all") => LoopMode::All,
Some("auto_pause") => LoopMode::AutoPause,
Some("autoplay") => LoopMode::Autoplay,
_ => LoopMode::None,
};

Expand All @@ -57,6 +58,7 @@ pub async fn execute<'a>(context: &Context, interaction: &CommandInteraction) ->
LoopMode::AutoPause => "loop.pause",
LoopMode::Single => "loop.music",
LoopMode::All => "loop.queue",
LoopMode::Autoplay => "loop.autoplay",
};

Cow::borrowed(t(&interaction.locale, loop_type_translation_key))
Expand Down Expand Up @@ -86,17 +88,18 @@ pub fn create_command() -> CreateCommand {
"The loop mode to set.",
)
.required(true)
.add_string_choice_localized("Default", "default", t_all("join.mode_default"))
.add_string_choice_localized("Single", "single", t_all("join.mode_single"))
.add_string_choice_localized("All", "all", t_all("join.mode_all"))
.add_string_choice_localized("Default", "default", t_all("loop.mode_default"))
.add_string_choice_localized("Single", "single", t_all("loop.mode_single"))
.add_string_choice_localized("All", "all", t_all("loop.mode_all"))
.add_string_choice_localized("Auto Pause", "auto_pause", t_all("loop.mode_auto_pause"))
.add_string_choice_localized(
"Auto Pause",
"auto_pause",
t_all("join.mode_auto_pause"),
"Autoplay",
"autoplay",
t_all("loop.mode_autoplay"),
);

option = serenity_command_option_name("join.mode_name", option);
option = serenity_command_option_description("join.mode_description", option);
option = serenity_command_option_name("loop.mode_name", option);
option = serenity_command_option_description("loop.mode_description", option);

option
})
Expand Down
1 change: 1 addition & 0 deletions hydrogen/src/components/loop_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub async fn execute<'a>(context: &Context, interaction: &ComponentInteraction)
LoopMode::AutoPause => "loop.pause",
LoopMode::Single => "loop.music",
LoopMode::All => "loop.queue",
LoopMode::Autoplay => "loop.autoplay",
};

Cow::borrowed(t(&interaction.locale, loop_type_translation_key))
Expand Down
15 changes: 9 additions & 6 deletions hydrogen/src/i18n/en_us.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ pub static TRANSLATIONS: Map<&'static str, &'static str> = phf_map! {
"join.template_queue" => "Queue",
"join.template_manual" => "Manual",
"join.template_rpg" => "RPG",
"join.template_autoplay" => "Autoplay",
"join.result" => "Created the player with the template **{0}**, now you can request any music using {1}.",
"stop.name" => "stop",
"stop.description" => "Stops the player.",
"stop.stopped" => "I'm leaving the voice channel. Hope to see you soon.",
"loop.name" => "loop",
"loop.description" => "Changes the loop mode of the player.",
"join.mode_name" => "mode",
"join.mode_description" => "The loop mode to set.",
"join.mode_default" => "Default",
"join.mode_single" => "Single",
"join.mode_all" => "All",
"join.mode_auto_pause" => "Auto Pause",
"loop.mode_name" => "mode",
"loop.mode_description" => "The loop mode to set.",
"loop.mode_default" => "Default",
"loop.mode_single" => "Single",
"loop.mode_all" => "All",
"loop.mode_auto_pause" => "Auto Pause",
"loop.mode_autoplay" => "Autoplay",
"loop.normal" => "Loop disabled, the player will start the next song automatically.",
"loop.pause" => "Loop disabled, the player will wait for you to start the next song.",
"loop.music" => "Looping the current song.",
"loop.queue" => "Looping the entire queue.",
"loop.autoplay" => "Autoplay enabled, the player will automatically add songs to the queue.",
"pause.name" => "pause",
"pause.description" => "Pauses or resumes the player.",
"pause.paused" => "You have paused the music player.",
Expand Down
15 changes: 9 additions & 6 deletions hydrogen/src/i18n/pt_br.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ pub static TRANSLATIONS: Map<&'static str, &'static str> = phf_map! {
"join.template_queue" => "Fila",
"join.template_manual" => "Manual",
"join.template_rpg" => "RPG",
"join.template_autoplay" => "Reprodução Automática",
"join.result" => "Criei o tocador de música com o template **{0}**, agora você pode pedir qualquer música usando {1}.",
"stop.name" => "parar",
"stop.description" => "Para o tocador de música.",
"stop.stopped" => "Eu estou saindo do chat de voz. Espero te ver em breve.",
"loop.name" => "loop",
"loop.description" => "Altera o modo de loop do tocador de música.",
"join.mode_name" => "modo",
"join.mode_description" => "O modo de loop para definir.",
"join.mode_default" => "Padrão",
"join.mode_single" => "Único",
"join.mode_all" => "Todos",
"join.mode_auto_pause" => "Pausa Automática",
"loop.mode_name" => "modo",
"loop.mode_description" => "O modo de loop para definir.",
"loop.mode_default" => "Padrão",
"loop.mode_single" => "Único",
"loop.mode_all" => "Todos",
"loop.mode_auto_pause" => "Pausa Automática",
"loop.mode_autoplay" => "Reprodução Automática",
"loop.normal" => "Loop desabilitado, o tocador de música começará a próxima música automaticamente.",
"loop.pause" => "Loop desabilitado, o tocador de música esperará você para começar a próxima música.",
"loop.music" => "Repetindo a música atual.",
"loop.queue" => "Repetindo a fila inteira.",
"loop.autoplay" => "Reprodução automática ativada, o tocador de música irá adicionar músicas automaticamente na fila.",
"pause.name" => "pausar",
"pause.description" => "Pausa ou resume o tocador de música.",
"pause.paused" => "Você pausou o tocador de música.",
Expand Down
1 change: 1 addition & 0 deletions hydrogen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl EventHandler for HydrogenHandler {
Arc::new(Cluster::new(lavalink_nodes, &ready.user.id.to_string()).await),
ctx.cache.clone(),
ctx.http.clone(),
ready.user.id,
)
.await,
)
Expand Down
Loading