forked from DiscordBots/Rustendo
feat: added current position to nowplaying command
This commit is contained in:
parent
eecb61b9f5
commit
a72f9753a2
5 changed files with 31 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
use crate::music::{music_queue};
|
||||
use crate::music::music_queue;
|
||||
use crate::util::embed::Embed;
|
||||
use futures::{FutureExt, TryFutureExt};
|
||||
use serenity::all::{CommandInteraction, Context};
|
||||
use serenity::builder::{CreateCommand, CreateEmbed};
|
||||
|
||||
|
@ -24,6 +25,13 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
|||
}
|
||||
};
|
||||
|
||||
let now_handle = match music_queue::get_now_playing_track_handle(&guild_id).await {
|
||||
Some(handle) => handle,
|
||||
None => {
|
||||
return Embed::create_error_respose(username, "Cannot get TrackHandle", "The TrackHandle is empty.");
|
||||
}
|
||||
};
|
||||
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
.expect("Cannot get Songbird")
|
||||
|
@ -35,7 +43,11 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
|||
return Embed::create_error_respose(username, "Error", "Error while getting the audio handler.");
|
||||
}
|
||||
};
|
||||
|
||||
let position = now_handle.get_info().await.unwrap().position;
|
||||
|
||||
Embed::create_yt_playing(now_plaing, username, "Currently playing").await
|
||||
.field("Position", format!("{}min {}sec", position.as_secs() / 60, position.as_secs() % 60), true)
|
||||
}
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue