turns out UpdatePresence and PresenceUpdate are different events

This commit is contained in:
kozabrada123 2023-06-10 16:32:42 +02:00
parent 57d2d93420
commit 330a4347d3
2 changed files with 20 additions and 6 deletions

View File

@ -235,10 +235,10 @@ impl GatewayHandle {
} }
/// Sends an update presence event to the gateway /// 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(); 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) self.send_json_event(GATEWAY_UPDATE_PRESENCE, to_send_value)
.await; .await;

View File

@ -1,14 +1,28 @@
use crate::types::events::WebSocketEvent;
use crate::types::interfaces::Activity; use crate::types::interfaces::Activity;
use crate::types::PublicUser; use crate::types::{events::WebSocketEvent, UserStatus};
use crate::types::{PublicUser, Snowflake};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, Clone)] #[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<u128>,
/// the client's status (online, invisible, offline, dnd, idle..)
pub status: UserStatus,
pub activities: Vec<Activity>,
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 /// See https://discord.com/developers/docs/topics/gateway-events#presence-update-presence-update-event-fields
pub struct PresenceUpdate { pub struct PresenceUpdate {
pub user: PublicUser, pub user: PublicUser,
pub guild_id: Option<String>, #[serde(default)]
pub status: String, pub guild_id: Option<Snowflake>,
pub status: UserStatus,
pub activities: Vec<Activity>, pub activities: Vec<Activity>,
pub client_status: ClientStatusObject, pub client_status: ClientStatusObject,
} }