trying to get handler to pause/play

This commit is contained in:
2024-10-11 11:22:05 -04:00
parent 2688d2304e
commit 38841369fc
8 changed files with 47 additions and 33 deletions

View File

@@ -13,6 +13,7 @@ use songbird::Songbird;
use crate::error::{SirenResult, Error as SirenError};
pub mod mute;
pub mod pause;
pub mod play;
pub mod resume;

View File

@@ -29,13 +29,20 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
// Pause the track
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
let handler = handler_lock.lock().await;
match handler.queue().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;
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;
}
}
}

View File

@@ -29,13 +29,21 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
// Resume the track
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
let handler = handler_lock.lock().await;
match handler.queue().resume() {
Ok(_) => {
log::debug!("<{guild_id}> Resumed the track");
edit_response(&ctx, &command, format!("Resuming the track")).await;
match handler.queue().current() {
Some(track) => {
match track.play() {
Ok(_) => {
log::debug!("<{guild_id}> Resumed the track");
edit_response(&ctx, &command, format!("Resuming the track")).await;
}
Err(err) => {
edit_response(&ctx, &command, format!("Failed to resume: {}", err)).await;
}
}
}
Err(err) => {
edit_response(&ctx, &command, format!("Failed to resume: {}", err)).await;
None => {
edit_response(&ctx, &command, format!("No track is currently playing")).await;
return;
}
}
}

View File

@@ -165,12 +165,12 @@ async fn generate_thread_name(oai: &OAI, s: &str, max_chars: usize) -> String {
let message = ChatCompletionMessage {
role: GPTRole::User,
content: format!(
"---\n{}\n---\nSummarize the message above into a concise Discord thread title",
s
"---\n{}\n---\nSummarize the message above into a concise Discord thread title with {} max characters",
s, max_chars
),
};
let request = ChatCompletionRequest {
model: oai.default_model.clone(),
model: "gpt-4o-mini".to_string(),
messages: vec![message],
temperature: Some(0.5),
top_p: None,

View File

@@ -52,6 +52,7 @@ impl EventHandler for Handler {
"stop" => commands::audio::stop::run(&ctx, &command).await,
"pause" => commands::audio::pause::run(&ctx, &command).await,
"resume" => commands::audio::resume::run(&ctx, &command).await,
"mute" => commands::audio::mute::run(&ctx, &command).await,
"skip" => commands::audio::skip::run(&ctx, &command).await,
"volume" => commands::audio::volume::run(&ctx, &command).await,
"schedule" => commands::event::schedule::run(&ctx, &command).await,
@@ -92,6 +93,7 @@ impl EventHandler for Handler {
commands::audio::stop::register(),
commands::audio::pause::register(),
commands::audio::resume::register(),
commands::audio::mute::register(),
commands::audio::skip::register(),
commands::audio::volume::register(),
commands::event::schedule::register(),

View File

@@ -10,7 +10,6 @@ use crate::bot::handler::Handler;
mod bot;
mod data;
mod dnd;
mod error;
pub struct HttpKey;