Add gateway Ready event

This commit is contained in:
kozabrada123 2023-05-05 16:08:12 +02:00
parent 07e500d063
commit c57122a94b
2 changed files with 21 additions and 0 deletions

View File

@ -134,6 +134,12 @@ pub struct Error {
pub code: String, pub code: String,
} }
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct UnavailableGuild {
id: String,
unavailable: bool
}
#[derive(Serialize, Deserialize, Debug, Default)] #[derive(Serialize, Deserialize, Debug, Default)]
pub struct UserObject { pub struct UserObject {
id: String, id: String,
@ -802,6 +808,18 @@ pub struct GatewayResume {
impl WebSocketEvent for GatewayResume {} impl WebSocketEvent for GatewayResume {}
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct GatewayReady {
pub v: u8,
pub user: UserObject,
pub guilds: Vec<UnavailableGuild>,
pub session_id: String,
pub resume_gateway_url: String,
pub shard: Option<(u64, u64)>,
}
impl WebSocketEvent for GatewayReady {}
#[derive(Debug, Default, Deserialize, Serialize)] #[derive(Debug, Default, Deserialize, Serialize)]
pub struct GatewayHello { pub struct GatewayHello {
pub op: i32, pub op: i32,

View File

@ -64,6 +64,9 @@ impl<'a> Gateway<'a> {
// See https://discord.com/developers/docs/topics/gateway-events#receive-events // See https://discord.com/developers/docs/topics/gateway-events#receive-events
match gateway_payload_t.as_str() { match gateway_payload_t.as_str() {
"READY" => {
let data: GatewayReady = serde_json::from_str(gateway_payload.d.unwrap().as_str()).unwrap();
}
"APPLICATION_COMMAND_PERMISSIONS_UPDATE" => {} "APPLICATION_COMMAND_PERMISSIONS_UPDATE" => {}
"AUTO_MODERATION_RULE_CREATE" => {} "AUTO_MODERATION_RULE_CREATE" => {}
"AUTO_MODERATION_RULE_UPDATE" => {} "AUTO_MODERATION_RULE_UPDATE" => {}