Fix typos

This commit is contained in:
bitfl0wer 2023-05-27 19:36:07 +02:00
parent 12a04e866a
commit 7f707d337e
2 changed files with 33 additions and 25 deletions

View File

@ -1,14 +1,14 @@
use crate::types::{AuditLogEntry, Emoji, Sticker, GuildMember, RoleObject, GuildScheduledEvent};
use crate::types::entities::{Guild, UnavailableGuild, User}; use crate::types::entities::{Guild, UnavailableGuild, User};
use crate::types::events::WebSocketEvent; use crate::types::events::WebSocketEvent;
use chrono::{Utc, DateTime}; use crate::types::{AuditLogEntry, Emoji, GuildMember, GuildScheduledEvent, RoleObject, Sticker};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::PresenceUpdate; use super::PresenceUpdate;
#[derive(Debug, Deserialize, Serialize, Default)] #[derive(Debug, Deserialize, Serialize, Default)]
/// See https://discord.com/developers/docs/topics/gateway-events#guild-create /// See https://discord.com/developers/docs/topics/gateway-events#guild-create
/// This one is particularly painful, it can be a Guild object with extra field or an unavailbile guild object /// This one is particularly painful, it can be a Guild object with an extra field or an unavailable guild object
pub struct GuildCreate { pub struct GuildCreate {
#[serde(flatten)] #[serde(flatten)]
pub d: GuildCreateDataOption, pub d: GuildCreateDataOption,
@ -50,7 +50,7 @@ impl WebSocketEvent for GuildBanRemove {}
/// See https://discord.com/developers/docs/topics/gateway-events#guild-update /// See https://discord.com/developers/docs/topics/gateway-events#guild-update
pub struct GuildUpdate { pub struct GuildUpdate {
#[serde(flatten)] #[serde(flatten)]
pub guild: Guild pub guild: Guild,
} }
impl WebSocketEvent for GuildUpdate {} impl WebSocketEvent for GuildUpdate {}
@ -59,7 +59,7 @@ impl WebSocketEvent for GuildUpdate {}
/// See https://discord.com/developers/docs/topics/gateway-events#guild-delete /// See https://discord.com/developers/docs/topics/gateway-events#guild-delete
pub struct GuildDelete { pub struct GuildDelete {
#[serde(flatten)] #[serde(flatten)]
pub guild: UnavailableGuild pub guild: UnavailableGuild,
} }
impl WebSocketEvent for GuildDelete {} impl WebSocketEvent for GuildDelete {}
@ -68,7 +68,7 @@ impl WebSocketEvent for GuildDelete {}
/// See https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create /// See https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create
pub struct GuildAuditLogEntryCreate { pub struct GuildAuditLogEntryCreate {
#[serde(flatten)] #[serde(flatten)]
pub entry: AuditLogEntry pub entry: AuditLogEntry,
} }
impl WebSocketEvent for GuildAuditLogEntryCreate {} impl WebSocketEvent for GuildAuditLogEntryCreate {}
@ -77,7 +77,7 @@ impl WebSocketEvent for GuildAuditLogEntryCreate {}
/// See https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update /// See https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update
pub struct GuildEmojisUpdate { pub struct GuildEmojisUpdate {
pub guild_id: String, pub guild_id: String,
pub emojis: Vec<Emoji> pub emojis: Vec<Emoji>,
} }
impl WebSocketEvent for GuildEmojisUpdate {} impl WebSocketEvent for GuildEmojisUpdate {}
@ -86,7 +86,7 @@ impl WebSocketEvent for GuildEmojisUpdate {}
/// See https://discord.com/developers/docs/topics/gateway-events#guild-stickers-update /// See https://discord.com/developers/docs/topics/gateway-events#guild-stickers-update
pub struct GuildStickersUpdate { pub struct GuildStickersUpdate {
pub guild_id: String, pub guild_id: String,
pub stickers: Vec<Sticker> pub stickers: Vec<Sticker>,
} }
impl WebSocketEvent for GuildStickersUpdate {} impl WebSocketEvent for GuildStickersUpdate {}
@ -145,7 +145,7 @@ pub struct GuildMembersChunk {
pub chunk_count: u16, pub chunk_count: u16,
pub not_found: Option<Vec<String>>, pub not_found: Option<Vec<String>>,
pub presences: Option<PresenceUpdate>, pub presences: Option<PresenceUpdate>,
pub nonce: Option<String> pub nonce: Option<String>,
} }
impl WebSocketEvent for GuildMembersChunk {} impl WebSocketEvent for GuildMembersChunk {}
@ -222,4 +222,4 @@ pub struct GuildScheduledEventUserRemove {
pub guild_id: String, pub guild_id: String,
} }
impl WebSocketEvent for GuildScheduledEventUserRemove {} impl WebSocketEvent for GuildScheduledEventUserRemove {}

View File

@ -15,7 +15,7 @@ pub struct GatewayIdentifyPayload {
pub presence: Option<PresenceUpdate>, pub presence: Option<PresenceUpdate>,
// What is the difference between these two? // What is the difference between these two?
// Intents is documented, capabilities is used in users // Intents is documented, capabilities is used in users
// I wonder if these are interchangable.. // I wonder if these are interchangeable...
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub intents: Option<i32>, pub intents: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -30,10 +30,19 @@ impl Default for GatewayIdentifyPayload {
impl GatewayIdentifyPayload { impl GatewayIdentifyPayload {
/// Uses the most common, 25% data along with client capabilities /// Uses the most common, 25% data along with client capabilities
/// ///
/// Basically pretends to be an official client on windows 10, with chrome 113.0.0.0 /// Basically pretends to be an official client on Windows 10, with Chrome 113.0.0.0
pub fn common() -> Self { pub fn common() -> Self {
Self { token: "".to_string(), properties: GatewayIdentifyConnectionProps::default(), compress: Some(false), large_threshold: None, shard: None, presence: None, intents: None, capabilities: Some(8189) } Self {
token: "".to_string(),
properties: GatewayIdentifyConnectionProps::default(),
compress: Some(false),
large_threshold: None,
shard: None,
presence: None,
intents: None,
capabilities: Some(8189),
}
} }
} }
@ -58,36 +67,36 @@ impl WebSocketEvent for GatewayIdentifyPayload {}
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct GatewayIdentifyConnectionProps { pub struct GatewayIdentifyConnectionProps {
/// Almost always sent /// Almost always sent
/// ///
/// ex: "Linux", "Windows", "Mac OS X" /// ex: "Linux", "Windows", "Mac OS X"
/// ///
/// ex (mobile): "Windows Mobile", "iOS", "Android", "BlackBerry" /// ex (mobile): "Windows Mobile", "iOS", "Android", "BlackBerry"
pub os: String, pub os: String,
/// Almost always sent /// Almost always sent
/// ///
/// ex: "Firefox", "Chrome", "Opera Mini", "Opera", "Blackberry", "Facebook Mobile", "Chrome iOS", "Mobile Safari", "Safari", "Android Chrome", "Android Mobile", "Edge", "Konqueror", "Internet Explorer", "Mozilla", "Discord Client" /// ex: "Firefox", "Chrome", "Opera Mini", "Opera", "Blackberry", "Facebook Mobile", "Chrome iOS", "Mobile Safari", "Safari", "Android Chrome", "Android Mobile", "Edge", "Konqueror", "Internet Explorer", "Mozilla", "Discord Client"
pub browser: String, pub browser: String,
/// Sometimes not sent, acceptable to be "" /// Sometimes not sent, acceptable to be ""
/// ///
/// Speculation: /// Speculation:
/// Only sent for mobile devices /// Only sent for mobile devices
/// ///
/// ex: "BlackBerry", "Windows Phone", "Android", "iPhone", "iPad", "" /// ex: "BlackBerry", "Windows Phone", "Android", "iPhone", "iPad", ""
pub device: String, pub device: String,
/// Almost always sent, most commonly en-US /// Almost always sent, most commonly en-US
/// ///
/// ex: "en-US" /// ex: "en-US"
pub system_locale: String, pub system_locale: String,
/// Almost always sent /// Almost always sent
/// ///
/// ex: any user agent, most common is "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" /// ex: any user agent, most common is "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
pub browser_user_agent: String, pub browser_user_agent: String,
/// Almost always sent /// Almost always sent
/// ///
/// ex: "113.0.0.0" /// ex: "113.0.0.0"
pub browser_version: String, pub browser_version: String,
/// Sometimes not sent, acceptable to be "" /// Sometimes not sent, acceptable to be ""
/// ///
/// ex: "10" (For os = "Windows") /// ex: "10" (For os = "Windows")
pub os_version: String, pub os_version: String,
/// Sometimes not sent, acceptable to be "" /// Sometimes not sent, acceptable to be ""
@ -111,7 +120,6 @@ impl Default for GatewayIdentifyConnectionProps {
} }
impl GatewayIdentifyConnectionProps { impl GatewayIdentifyConnectionProps {
/// Returns a minimal, least data possible default /// Returns a minimal, least data possible default
fn minimal() -> Self { fn minimal() -> Self {
Self { Self {
@ -150,4 +158,4 @@ impl GatewayIdentifyConnectionProps {
return default; return default;
} }
} }