RMusicBot/src/player/commands/pause.rs

34 lines
740 B
Rust
Raw Normal View History

2018-11-14 14:29:58 +00:00
use serenity;
use super::super::prelude::*;
2019-07-12 08:39:03 +00:00
use serenity::prelude::*;
use serenity::{
framework::standard::{macros::command, Args, CommandResult},
model::channel::Message,
};
#[command]
fn pause(ctx: &mut Context, msg: &Message, _: Args) -> CommandResult {
if !channel_contains_author(ctx, msg) {
println!(
"user {} is not in the same voice channel as the bot",
msg.author.name
);
return Ok(());
2018-11-14 14:29:58 +00:00
}
2019-07-12 08:39:03 +00:00
let data = ctx.data.read();
let media = match data.get::<MediaData>() {
Ok(media) => media,
Err(_) => {
msg.channel_id.say("could not find media data");
2018-11-23 12:18:07 +00:00
return Ok(());
}
2019-07-12 08:39:03 +00:00
};
2018-11-23 12:18:07 +00:00
2019-07-12 08:39:03 +00:00
media.song().pause();
2018-11-14 14:29:58 +00:00
2019-07-12 08:39:03 +00:00
Ok(())
2018-11-14 14:29:58 +00:00
}