aboutsummaryrefslogtreecommitdiff
path: root/src/audio/mod.rs
blob: 9affdb192f20bb3668b802ef038a95fa33294925 (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
use std::sync::Arc;

use chrono::Duration;
use either::Either;
use serenity::{
    model::id::ChannelId,
    prelude::*,
};
use typemap::Key;

pub use self::{
    play_queue::PlayQueue,
    timeutil::parse_times,
    ytdl::*,
};

mod play_queue;
mod timeutil;
mod ytdl;

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,
}