Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #430 #440

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/types/entities/voice_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.spacebar.chat/routes/#cmp--schemas-voicestate>
#[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<Snowflake>,
pub guild: Option<Guild>,
pub channel_id: Option<Snowflake>,
pub user_id: Snowflake,
pub member: Option<Arc<RwLock<GuildMember>>>,
pub session_id: Snowflake,
pub session_id: String,
pub token: Option<String>,
pub deaf: bool,
pub mute: bool,
Expand All @@ -38,5 +41,15 @@ pub struct VoiceState {
pub self_video: bool,
pub suppress: bool,
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
}
}
}
Loading