diff --git a/src/types/entities/voice_state.rs b/src/types/entities/voice_state.rs index e764296..6bc45e2 100644 --- a/src/types/entities/voice_state.rs +++ b/src/types/entities/voice_state.rs @@ -18,17 +18,20 @@ use crate::types::{ utils::Snowflake, }; +/// The VoiceState struct. Note, that Discord does not have an `id` field for this, whereas Spacebar +/// does. +/// /// See #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] -#[cfg_attr(feature = "client", derive(Updateable, Composite))] +#[cfg_attr(feature = "client", derive(Composite))] pub struct VoiceState { pub guild_id: Option, pub guild: Option, pub channel_id: Option, pub user_id: Snowflake, pub member: Option>>, - pub session_id: Snowflake, + pub session_id: String, pub token: Option, pub deaf: bool, pub mute: bool, @@ -38,5 +41,15 @@ pub struct VoiceState { pub self_video: bool, pub suppress: bool, pub request_to_speak_timestamp: Option>, - pub id: Snowflake, + pub id: Option, // Only exists on Spacebar +} + +impl Updateable for VoiceState { + fn id(&self) -> Snowflake { + if let Some(id) = self.id { + id // ID exists: Only the case for Spacebar Server impls + } else { + self.user_id // ID doesn't exist: Discord does not have the ID field - ID is void + } + } }