Add Stage Instance & events
This commit is contained in:
parent
8d0083e11d
commit
5b04370d46
|
@ -462,9 +462,18 @@ impl Gateway {
|
||||||
let new_data: types::RelationshipRemove = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
let new_data: types::RelationshipRemove = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
||||||
self.events.lock().await.relationship.remove.update_data(new_data).await;
|
self.events.lock().await.relationship.remove.update_data(new_data).await;
|
||||||
}
|
}
|
||||||
"STAGE_INSTANCE_CREATE" => {}
|
"STAGE_INSTANCE_CREATE" => {
|
||||||
"STAGE_INSTANCE_UPDATE" => {}
|
let new_data: types::StageInstanceCreate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
||||||
"STAGE_INSTANCE_DELETE" => {}
|
self.events.lock().await.stage_instance.create.update_data(new_data).await;
|
||||||
|
}
|
||||||
|
"STAGE_INSTANCE_UPDATE" => {
|
||||||
|
let new_data: types::StageInstanceUpdate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
||||||
|
self.events.lock().await.stage_instance.update.update_data(new_data).await;
|
||||||
|
}
|
||||||
|
"STAGE_INSTANCE_DELETE" => {
|
||||||
|
let new_data: types::StageInstanceDelete = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
||||||
|
self.events.lock().await.stage_instance.delete.update_data(new_data).await;
|
||||||
|
}
|
||||||
"SESSIONS_REPLACE" => {
|
"SESSIONS_REPLACE" => {
|
||||||
let sessions: Vec<types::Session> = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
let sessions: Vec<types::Session> = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
|
||||||
let new_data = types::SessionsReplace {sessions};
|
let new_data = types::SessionsReplace {sessions};
|
||||||
|
@ -714,6 +723,7 @@ mod events {
|
||||||
pub guild: Guild,
|
pub guild: Guild,
|
||||||
pub invite: Invite,
|
pub invite: Invite,
|
||||||
pub integration: Integration,
|
pub integration: Integration,
|
||||||
|
pub stage_instance: StageInstance,
|
||||||
pub call: Call,
|
pub call: Call,
|
||||||
pub voice: Voice,
|
pub voice: Voice,
|
||||||
pub webhooks: Webhooks,
|
pub webhooks: Webhooks,
|
||||||
|
@ -736,6 +746,13 @@ mod events {
|
||||||
pub replace: GatewayEvent<types::SessionsReplace>
|
pub replace: GatewayEvent<types::SessionsReplace>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct StageInstance {
|
||||||
|
pub create: GatewayEvent<types::StageInstanceCreate>,
|
||||||
|
pub update: GatewayEvent<types::StageInstanceUpdate>,
|
||||||
|
pub delete: GatewayEvent<types::StageInstanceDelete>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub create: GatewayEvent<types::MessageCreate>,
|
pub create: GatewayEvent<types::MessageCreate>,
|
||||||
|
|
|
@ -19,6 +19,7 @@ mod webhook;
|
||||||
mod audit_log;
|
mod audit_log;
|
||||||
mod relationship;
|
mod relationship;
|
||||||
mod auto_moderation;
|
mod auto_moderation;
|
||||||
|
mod stage_instance;
|
||||||
|
|
||||||
pub use application::*;
|
pub use application::*;
|
||||||
pub use attachment::*;
|
pub use attachment::*;
|
||||||
|
@ -41,3 +42,4 @@ pub use webhook::*;
|
||||||
pub use audit_log::*;
|
pub use audit_log::*;
|
||||||
pub use relationship::*;
|
pub use relationship::*;
|
||||||
pub use auto_moderation::*;
|
pub use auto_moderation::*;
|
||||||
|
pub use stage_instance::*;
|
|
@ -0,0 +1,29 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_repr::{Serialize_repr, Deserialize_repr};
|
||||||
|
|
||||||
|
use crate::types::Snowflake;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||||
|
/// See https://discord.com/developers/docs/resources/stage-instance
|
||||||
|
pub struct StageInstance {
|
||||||
|
pub id: Snowflake,
|
||||||
|
pub guild_id: Snowflake,
|
||||||
|
pub channel_id: Snowflake,
|
||||||
|
/// 1 - 120 chars
|
||||||
|
pub topic: String,
|
||||||
|
pub privacy_level: StageInstancePrivacyLevel,
|
||||||
|
/// deprecated, apparently
|
||||||
|
pub discoverable_disabled: Option<bool>,
|
||||||
|
pub guild_scheduled_event_id: Option<Snowflake>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default)]
|
||||||
|
#[repr(u8)]
|
||||||
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
|
/// See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
|
||||||
|
pub enum StageInstancePrivacyLevel {
|
||||||
|
/// deprecated, apparently
|
||||||
|
Public = 1,
|
||||||
|
#[default]
|
||||||
|
GuildOnly = 2
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ mod call;
|
||||||
mod lazy_request;
|
mod lazy_request;
|
||||||
mod relationship;
|
mod relationship;
|
||||||
mod auto_moderation;
|
mod auto_moderation;
|
||||||
|
mod stage_instance;
|
||||||
|
|
||||||
pub use channel::*;
|
pub use channel::*;
|
||||||
pub use guild::*;
|
pub use guild::*;
|
||||||
|
@ -45,6 +46,7 @@ pub use call::*;
|
||||||
pub use lazy_request::*;
|
pub use lazy_request::*;
|
||||||
pub use relationship::*;
|
pub use relationship::*;
|
||||||
pub use auto_moderation::*;
|
pub use auto_moderation::*;
|
||||||
|
pub use stage_instance::*;
|
||||||
|
|
||||||
pub trait WebSocketEvent {}
|
pub trait WebSocketEvent {}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::types::{WebSocketEvent, StageInstance};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||||
|
/// See https://discord.com/developers/docs/topics/gateway-events#stage-instance-create
|
||||||
|
pub struct StageInstanceCreate {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub stage_instance: StageInstance,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WebSocketEvent for StageInstanceCreate {}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||||
|
/// See https://discord.com/developers/docs/topics/gateway-events#stage-instance-update
|
||||||
|
pub struct StageInstanceUpdate {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub stage_instance: StageInstance,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WebSocketEvent for StageInstanceUpdate {}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||||
|
/// See https://discord.com/developers/docs/topics/gateway-events#stage-instance-delete
|
||||||
|
pub struct StageInstanceDelete {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub stage_instance: StageInstance,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WebSocketEvent for StageInstanceDelete {}
|
Loading…
Reference in New Issue