Add rest of send events

This commit is contained in:
kozabrada123 2023-05-13 15:59:46 +02:00
parent 595716afc5
commit 11d371eee2
2 changed files with 46 additions and 0 deletions

View File

@ -803,6 +803,30 @@ pub struct GatewayReady {
impl WebSocketEvent for GatewayReady {}
#[derive(Debug, Deserialize, Serialize, Default)]
/// See https://discord.com/developers/docs/topics/gateway-events#request-guild-members-request-guild-members-structure
pub struct GatewayRequestGuildMembers {
pub guild_id: String,
pub query: Option<String>,
pub limit: u64,
pub presence: Option<bool>,
pub user_ids: Option<String>,
pub nonce: Option<String>,
}
impl WebSocketEvent for GatewayRequestGuildMembers {}
#[derive(Debug, Deserialize, Serialize, Default)]
/// See https://discord.com/developers/docs/topics/gateway-events#update-voice-state-gateway-voice-state-update-structure
pub struct GatewayVoiceStateUpdate {
pub guild_id: String,
pub channel_id: Option<String>,
pub self_mute: bool,
pub self_deaf: bool,
}
impl WebSocketEvent for GatewayVoiceStateUpdate {}
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct GatewayHello {
pub op: i32,

View File

@ -69,8 +69,30 @@ impl GatewayHandle {
let to_send_value = serde_json::to_value(&to_send).unwrap();
println!("GW: Sending Presence Update..");
self.send_json_event(3, to_send_value).await;
}
/// Sends a Request Guild Members to the server
pub async fn send_request_guild_members(&self, to_send: GatewayRequestGuildMembers) {
let to_send_value = serde_json::to_value(&to_send).unwrap();
println!("GW: Sending Request Guild Members..");
self.send_json_event(8, to_send_value).await;
}
/// Sends a Request Guild Members to the server
pub async fn send_update_voice_state(&self, to_send: GatewayVoiceStateUpdate) {
let to_send_value = serde_json::to_value(&to_send).unwrap();
println!("GW: Sending Voice State Update..");
self.send_json_event(4, to_send_value).await;
}
}
pub struct Gateway {