1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
use serenity::{
framework::standard::{
macros::command,
Args,
CommandResult,
},
model::channel::Message,
prelude::*,
};
use crate::commands::songbird;
pub const DEFAULT_VOLUME: f32 = 0.20;
const MAX_VOLUME: f32 = 5.0;
#[command]
pub async fn mute(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
let (_sb, call) = songbird(ctx, msg).await?;
let mut call = call.lock().await;
call.mute(true).await?;
Ok(())
}
#[command]
pub async fn unmute(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
let (_sb, call) = songbird(ctx, msg).await?;
let mut call = call.lock().await;
call.mute(true).await?;
Ok(())
}
// #[command]
// pub async fn volume(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
// if args.len() == 0 {
// let vol = {
// let queue_lock = ctx.data.write().await.get::<PlayQueue>().cloned().unwrap();
// let play_queue = queue_lock.read().unwrap();
// (play_queue.volume / DEFAULT_VOLUME * 100.0) as usize
// };
//
// trace!("reporting volume {}", vol);
//
// return util::send(ctx, msg.channel_id, &format!("volume: {}%", vol), msg.tts)
// .map_err(CommandError::from)
// .await;
// }
//
// let vol: usize = match args.single::<f32>() {
// Ok(vol) if vol.is_nan() => {
// warn!("reporting NaN volume");
// return util::send(ctx, msg.channel_id, "you're a fuck", msg.tts)
// .map_err(CommandError::from)
// .await;
// },
// Ok(vol) => vol as usize,
// Err(e) => {
// error!("parsing volume arg: {}", e);
// return util::send(ctx, msg.channel_id, "???????", msg.tts)
// .map_err(CommandError::from)
// .await;
// },
// };
//
// let mut vol: f32 = (vol as f32) / 100.0; // force aliasing to reasonable values
// let adjusted_text = if vol > MAX_VOLUME {
// format!(" ({:.0}% max)", MAX_VOLUME * 100.0)
// } else {
// "".to_owned()
// };
//
// vol = vol.clamp(0.0, MAX_VOLUME);
//
// let queue_lock = ctx.data.write().await.get::<PlayQueue>().cloned().unwrap();
//
// {
// let mut play_queue = queue_lock.write().unwrap();
// play_queue.volume = vol * DEFAULT_VOLUME;
// info!("volume updated to {}", vol);
// }
//
// util::send(ctx, msg.channel_id, format!("volume adjusted{}", adjusted_text), msg.tts).await?;
//
// Ok(())
// }
|