Cleanup commands

This commit is contained in:
2024-09-05 13:12:39 -04:00
parent 399eb8a29d
commit 3994c18c49
9 changed files with 182 additions and 278 deletions

View File

@@ -1,39 +1,34 @@
use log::{debug, error};
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
if let Err(why) = create_response(&ctx, &command, "Processing command...".to_string()).await {
error!("Failed to create response message: {}", why);
return;
}
create_response(&ctx, &command, format!(".....")).await;
let guild_id = match command.guild_id {
Some(g) => g,
// 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 => {
if let Err(why) =
edit_response(&ctx, &command, "Unable to join voice channel".to_string()).await
{
error!("Failed to edit response message: {}", why);
}
edit_response(&ctx, &command, "Unable to find the current server ID".to_string()).await;
return;
}
};
let manager = get_songbird(ctx).await;
if let Some(handler_lock) = manager.get(guild_id) {
// Skip the track
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
let handler = handler_lock.lock().await;
if let Err(err) = handler.queue().skip() {
if let Err(why) = edit_response(&ctx, &command, format!("Failed to skip: {}", err)).await {
error!("Failed to edit response message: {}", why);
}
} else {
debug!("Skipped the track");
if let Err(why) = edit_response(&ctx, &command, format!("Skipping the track")).await {
error!("Failed to edit response message: {}", why);
}
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;
}
}
}
}