Add Invite Create & Delete

This commit is contained in:
kozabrada123 2023-05-20 12:50:05 +02:00
parent c2320b263b
commit 5550186ca3
2 changed files with 34 additions and 2 deletions

View File

@ -1611,6 +1611,25 @@ pub struct IntegrationDelete {
impl WebSocketEvent for IntegrationDelete {}
#[derive(Debug, Default, Deserialize, Serialize)]
/// See https://discord.com/developers/docs/topics/gateway-events#invite-create
pub struct InviteCreate {
#[serde(flatten)]
pub invite: GuildInvite
}
impl WebSocketEvent for InviteCreate {}
#[derive(Debug, Default, Deserialize, Serialize)]
/// See https://discord.com/developers/docs/topics/gateway-events#invite-delete
pub struct InviteDelete {
pub channel_id: String,
pub guild_id: Option<String>,
pub code: String,
}
impl WebSocketEvent for InviteDelete {}
#[derive(Debug, Deserialize, Serialize, Default)]
/// Officially Undocumented
/// Is sent to a client by the server to signify a new being created

View File

@ -357,8 +357,14 @@ impl Gateway {
self.events.lock().await.integration.delete.update_data(new_data).await;
}
"INTERACTION_CREATE" => {}
"INVITE_CREATE" => {}
"INVITE_DELETE" => {}
"INVITE_CREATE" => {
let new_data: InviteCreate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.invite.create.update_data(new_data).await;
}
"INVITE_DELETE" => {
let new_data: InviteDelete = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.invite.delete.update_data(new_data).await;
}
"MESSAGE_CREATE" => {
let new_data: MessageCreate = serde_json::from_str(gateway_payload.d.unwrap().get()).unwrap();
self.events.lock().await.message.create.update_data(new_data).await;
@ -616,6 +622,7 @@ mod events {
pub channel: Channel,
pub thread: Thread,
pub guild: Guild,
pub invite: Invite,
pub integration: Integration,
pub call: Call,
pub webhooks: Webhooks,
@ -695,6 +702,12 @@ mod events {
pub passive_update_v1: GatewayEvent<PassiveUpdateV1>,
}
#[derive(Default, Debug)]
pub struct Invite {
pub create: GatewayEvent<InviteCreate>,
pub delete: GatewayEvent<InviteDelete>
}
#[derive(Default, Debug)]
pub struct Integration {
pub create: GatewayEvent<IntegrationCreate>,