Add Passive Update V1

This commit is contained in:
kozabrada123 2023-05-20 09:35:48 +02:00
parent 1a98e7db6b
commit b207521bbd
2 changed files with 20 additions and 3 deletions

View File

@ -1347,7 +1347,8 @@ pub struct ChannelUnreadUpdate {
/// See also [ChannelUnreadUpdates] /// See also [ChannelUnreadUpdates]
pub struct ChannelUnreadUpdateObject { pub struct ChannelUnreadUpdateObject {
pub id: String, pub id: String,
pub last_message_id: String pub last_message_id: String,
pub last_pin_timestamp: Option<String>
} }
impl WebSocketEvent for ChannelUnreadUpdate {} impl WebSocketEvent for ChannelUnreadUpdate {}
@ -1567,6 +1568,19 @@ pub struct GuildRoleDelete {
impl WebSocketEvent for GuildRoleDelete {} impl WebSocketEvent for GuildRoleDelete {}
#[derive(Debug, Deserialize, Serialize, Default)]
/// Officially Undocumented
///
/// Seems to be passively set to update the client on guild details (though, why not just send the update events?)
pub struct PassiveUpdateV1 {
pub voice_states: Vec<VoiceState>,
pub members: Vec<GuildMember>,
pub guild_id: String,
pub channels: Vec<ChannelUnreadUpdateObject>,
}
impl WebSocketEvent for PassiveUpdateV1 {}
#[derive(Debug, Default, Deserialize, Serialize)] #[derive(Debug, Default, Deserialize, Serialize)]
/// See https://discord.com/developers/docs/topics/gateway-events#integration-create /// See https://discord.com/developers/docs/topics/gateway-events#integration-create
pub struct IntegrationCreate { pub struct IntegrationCreate {

View File

@ -340,6 +340,10 @@ impl Gateway {
"GUILD_SCHEDULED_EVENT_DELETE" => {} "GUILD_SCHEDULED_EVENT_DELETE" => {}
"GUILD_SCHEDULED_EVENT_USER_ADD" => {} "GUILD_SCHEDULED_EVENT_USER_ADD" => {}
"GUILD_SCHEDULED_EVENT_USER_REMOVE" => {} "GUILD_SCHEDULED_EVENT_USER_REMOVE" => {}
"PASSIVE_UPDATE_V1" => {
let new_data: PassiveUpdateV1 = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.guild.passive_update_v1.update_data(new_data).await;
}
"INTEGRATION_CREATE" => { "INTEGRATION_CREATE" => {
let new_data: IntegrationCreate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap(); let new_data: IntegrationCreate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.integration.create.update_data(new_data).await; self.events.lock().await.integration.create.update_data(new_data).await;
@ -395,8 +399,6 @@ impl Gateway {
let new_data: PresenceUpdate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap(); let new_data: PresenceUpdate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.user.presence_update.update_data(new_data).await; self.events.lock().await.user.presence_update.update_data(new_data).await;
} }
// What is this?
"PASSIVE_UPDATE_V1" => {}
"STAGE_INSTANCE_CREATE" => {} "STAGE_INSTANCE_CREATE" => {}
"STAGE_INSTANCE_UPDATE" => {} "STAGE_INSTANCE_UPDATE" => {}
"STAGE_INSTANCE_DELETE" => {} "STAGE_INSTANCE_DELETE" => {}
@ -690,6 +692,7 @@ mod events {
pub role_scheduled_event_delete: GatewayEvent<ThreadCreate>, pub role_scheduled_event_delete: GatewayEvent<ThreadCreate>,
pub role_scheduled_event_user_add: GatewayEvent<ThreadCreate>, pub role_scheduled_event_user_add: GatewayEvent<ThreadCreate>,
pub role_scheduled_event_user_remove: GatewayEvent<ThreadCreate>,*/ pub role_scheduled_event_user_remove: GatewayEvent<ThreadCreate>,*/
pub passive_update_v1: GatewayEvent<PassiveUpdateV1>,
} }
#[derive(Default, Debug)] #[derive(Default, Debug)]