Fixes #430
This commit is contained in:
Flori 2023-11-14 17:59:53 +01:00 committed by GitHub
commit 5ca56d57a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -18,17 +18,20 @@ use crate::types::{
utils::Snowflake, utils::Snowflake,
}; };
/// The VoiceState struct. Note, that Discord does not have an `id` field for this, whereas Spacebar
/// does.
///
/// See <https://docs.spacebar.chat/routes/#cmp--schemas-voicestate> /// See <https://docs.spacebar.chat/routes/#cmp--schemas-voicestate>
#[derive(Serialize, Deserialize, Debug, Default, Clone)] #[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[cfg_attr(feature = "client", derive(Updateable, Composite))] #[cfg_attr(feature = "client", derive(Composite))]
pub struct VoiceState { pub struct VoiceState {
pub guild_id: Option<Snowflake>, pub guild_id: Option<Snowflake>,
pub guild: Option<Guild>, pub guild: Option<Guild>,
pub channel_id: Option<Snowflake>, pub channel_id: Option<Snowflake>,
pub user_id: Snowflake, pub user_id: Snowflake,
pub member: Option<Arc<RwLock<GuildMember>>>, pub member: Option<Arc<RwLock<GuildMember>>>,
pub session_id: Snowflake, pub session_id: String,
pub token: Option<String>, pub token: Option<String>,
pub deaf: bool, pub deaf: bool,
pub mute: bool, pub mute: bool,
@ -38,5 +41,15 @@ pub struct VoiceState {
pub self_video: bool, pub self_video: bool,
pub suppress: bool, pub suppress: bool,
pub request_to_speak_timestamp: Option<DateTime<Utc>>, pub request_to_speak_timestamp: Option<DateTime<Utc>>,
pub id: Snowflake, pub id: Option<Snowflake>, // 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
}
}
} }