Removed audio gitignore
This commit is contained in:
52
src/bot/commands/audio/mute.rs
Normal file
52
src/bot/commands/audio/mute.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
// Mute the track
|
||||
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
||||
let mut handler = handler_lock.lock().await;
|
||||
let is_muted = handler.is_mute();
|
||||
match handler.mute(!is_muted).await {
|
||||
Ok(_) => {
|
||||
if is_muted {
|
||||
log::debug!("<{guild_id}> Unmuted");
|
||||
edit_response(&ctx, &command, format!("Unmuted")).await;
|
||||
} else {
|
||||
log::debug!("<{guild_id}> Muted");
|
||||
edit_response(&ctx, &command, format!("Muted")).await;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
edit_response(&ctx, &command, format!("Failed to mute: {}", err)).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("mute").description("Mute/unmute Siren")
|
||||
}
|
||||
Reference in New Issue
Block a user