39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
use serenity::{all::{CommandInteraction, CreateCommand}, prelude::*};
|
|
|
|
use super::{get_songbird, create_response, edit_response};
|
|
|
|
pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
|
// Create the initial response
|
|
create_response(&ctx, &command, format!(".....")).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;
|
|
}
|
|
};
|
|
|
|
// Skip the track
|
|
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
|
let handler = handler_lock.lock().await;
|
|
match handler.queue().skip() {
|
|
Ok(_) => {
|
|
log::debug!("Skipped the track");
|
|
edit_response(&ctx, &command, format!("Skipping the track")).await;
|
|
},
|
|
Err(err) => {
|
|
edit_response(&ctx, &command, format!("Failed to skip: {}", err)).await;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn register() -> CreateCommand {
|
|
CreateCommand::new("skip").description("Skip the current track")
|
|
}
|