52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
use serenity::{
|
|
all::{CommandInteraction, CreateCommand},
|
|
prelude::*,
|
|
};
|
|
|
|
use super::{edit_response, get_songbird, process_message};
|
|
|
|
pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
|
// Create the initial response
|
|
process_message(&ctx, &command).await;
|
|
|
|
// Get the songbird manager
|
|
let manager = get_songbird(ctx).await;
|
|
|
|
// Extract the guild ID
|
|
let guild_id = match &command.guild_id {
|
|
Some(guild_id) => guild_id,
|
|
None => {
|
|
edit_response(
|
|
&ctx,
|
|
&command,
|
|
"Unable to find the current server ID".to_string(),
|
|
)
|
|
.await;
|
|
return;
|
|
}
|
|
};
|
|
|
|
// Pause the track
|
|
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
|
let handler = handler_lock.lock().await;
|
|
match handler.queue().current() {
|
|
Some(track) => match track.pause() {
|
|
Ok(_) => {
|
|
log::debug!("<{guild_id}> Paused the track");
|
|
edit_response(&ctx, &command, format!("Pausing the track")).await;
|
|
}
|
|
Err(err) => {
|
|
edit_response(&ctx, &command, format!("Failed to pause: {}", err)).await;
|
|
}
|
|
},
|
|
None => {
|
|
edit_response(ctx, command, format!("No track currently being played")).await;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn register() -> CreateCommand {
|
|
CreateCommand::new("pause").description("Pause the current track")
|
|
}
|