aboutsummaryrefslogtreecommitdiff
path: root/src/audio/mod.rs
blob: 3c3041f9c1e6f23c1ad885973ae323dfebcb361f (plain) (blame)
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
use std::sync::Arc;

use chrono::Duration;
use either::Either;
use serenity::{
    client::bridge::voice::ClientVoiceManager,
    model::{
        id::{
            ChannelId,
        },
    },
    prelude::*,
    voice::LockedAudio,
};
use typemap::Key;

pub use self::play_queue::PlayQueue;
pub use self::timeutil::parse_times;
pub use self::ytdl::*;

mod timeutil;
mod ytdl;
mod play_queue;

pub struct VoiceManager;

impl Key for VoiceManager {
    type Value = Arc<Mutex<ClientVoiceManager>>;
}

impl VoiceManager {
    pub fn register(c: &mut Client) {
        let mut data = c.data.write();
        data.insert::<VoiceManager>(Arc::clone(&c.voice_manager));
    }
}

#[derive(Clone, Debug)]
pub struct PlayArgs {
    pub data: Either<String, Vec<u8>>,
    pub initiator: String,
    pub sender_channel: ChannelId,
    pub start: Option<Duration>,
    pub end: Option<Duration>,
}

#[derive(Clone)]
pub struct CurrentItem {
    pub init_args: PlayArgs,
    pub audio: LockedAudio,
}