Play api request

This commit is contained in:
2024-12-19 21:46:52 -05:00
parent a97505ea5e
commit 9a144bab4d
19 changed files with 172 additions and 103 deletions

View File

@@ -1,6 +1,7 @@
use std::sync::Arc;
use std::sync::{Arc, OnceLock};
use reqwest::Url;
use serenity::all::UserId;
use serenity::client::Cache;
use serenity::model::prelude::{GuildId, ChannelId};
use serenity::model::user::User;
@@ -17,12 +18,6 @@ pub mod skip;
pub mod stop;
pub mod volume;
pub async fn get_songbird(ctx: &Context) -> Arc<Songbird> {
songbird::get(ctx)
.await
.expect("Songbird Voice client placed in at initialization")
}
/**
* Finds a voice channel that the user is currently in, and attempts to join it.
*/
@@ -30,9 +25,9 @@ pub async fn join_voice_channel(
cache: &Arc<Cache>,
manager: &Arc<Songbird>,
guild_id: &GuildId,
user: &User,
user_id: &UserId,
) -> SirenResult<ChannelId> {
let channel_id = find_voice_channel(cache, guild_id, user)?;
let channel_id = find_voice_channel(cache, guild_id, user_id)?;
log::debug!("<{}> Joining channel {}", guild_id.get(), channel_id.get());
manager
.join(guild_id.to_owned(), channel_id.to_owned())
@@ -66,7 +61,7 @@ fn is_valid_url(url: &str) -> bool {
fn find_voice_channel(
cache: &Arc<Cache>,
guild_id: &GuildId,
user: &User,
user_id: &UserId,
) -> SirenResult<ChannelId> {
let guild = match guild_id.to_guild_cached(cache) {
Some(g) => g,
@@ -75,7 +70,7 @@ fn find_voice_channel(
match guild
.voice_states
.get(&user.id)
.get(&user_id)
.and_then(|voice_state| voice_state.channel_id)
{
Some(channel) => Ok(channel),