You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, first thing first, I don't mean to be rude, sorry if it sound like that. I'm not native English speaker.
in the previous version, I was using TrackHandle.metadata() a lot throughout my code. but browsing through this crate source code now seems like it doesn't store there anymore
Question: Do I need to store it myself?
Here's my current code
usecrate::{Context,Error};#[poise::command(slash_command, guild_only)]pubasyncfnskip(ctx:Context<'_>) -> Result<(),Error>{
ctx.defer().await?;let manager = songbird::get(ctx.serenity_context()).await.expect("songbird init at main").clone();let(guild_id, user_channel) = {// CacheRef can't live pass .await unless clone but we don't want thatlet guild = ctx.guild().expect("Not in a guild");let user_channel = guild
.voice_states.get(&ctx.author().id).and_then(|v| v.channel_id);(guild.id, user_channel)};if user_channel.is_none(){
ctx.say("You are not in a voice channel").await?;returnOk(());}let handler_lock = match manager.get(guild_id){Some(l) => l,None => {
ctx.say("I'm not in a voice channel").await?;returnOk(());}};let track = {let handler = handler_lock.lock().await;let queue = handler.queue();let current_track = queue.current();if current_track.is_none(){None}else{
queue.skip()?;
current_track
}};let message = if track.is_none(){"Queue is empty".to_string()}else{// I used to do this ----> // format!("Skipped: {}", track.unwrap().metadata().title.unwrap())"Skipped".to_string()};
ctx.say(message).await?;Ok(())}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, first thing first, I don't mean to be rude, sorry if it sound like that. I'm not native English speaker.
in the previous version, I was using
TrackHandle.metadata()
a lot throughout my code. but browsing through this crate source code now seems like it doesn't store there anymoreQuestion: Do I need to store it myself?
Here's my current code
Beta Was this translation helpful? Give feedback.
All reactions