diff --git a/src/gateway.rs b/src/gateway.rs index e49e491..c8c5be9 100644 --- a/src/gateway.rs +++ b/src/gateway.rs @@ -235,10 +235,10 @@ impl GatewayHandle { } /// Sends an update presence event to the gateway - pub async fn send_update_presence(&self, to_send: types::PresenceUpdate) { + pub async fn send_update_presence(&self, to_send: types::UpdatePresence) { let to_send_value = serde_json::to_value(&to_send).unwrap(); - println!("GW: Sending Presence Update.."); + println!("GW: Sending Update Presence.."); self.send_json_event(GATEWAY_UPDATE_PRESENCE, to_send_value) .await; diff --git a/src/types/events/presence.rs b/src/types/events/presence.rs index dd49fde..aacc170 100644 --- a/src/types/events/presence.rs +++ b/src/types/events/presence.rs @@ -1,14 +1,28 @@ -use crate::types::events::WebSocketEvent; use crate::types::interfaces::Activity; -use crate::types::PublicUser; +use crate::types::{events::WebSocketEvent, UserStatus}; +use crate::types::{PublicUser, Snowflake}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Default, Clone)] +/// Sent by the client to update its status and presence; +/// See https://discord.com/developers/docs/topics/gateway-events#update-presence +pub struct UpdatePresence { + /// unix time of when the client went idle, or none if client is not idle + pub since: Option, + /// the client's status (online, invisible, offline, dnd, idle..) + pub status: UserStatus, + pub activities: Vec, + pub afk: bool, +} + +#[derive(Debug, Deserialize, Serialize, Default, Clone)] +/// Received to tell the client that a user updated their presence / status /// See https://discord.com/developers/docs/topics/gateway-events#presence-update-presence-update-event-fields pub struct PresenceUpdate { pub user: PublicUser, - pub guild_id: Option, - pub status: String, + #[serde(default)] + pub guild_id: Option, + pub status: UserStatus, pub activities: Vec, pub client_status: ClientStatusObject, }