diff --git a/src/api/types.rs b/src/api/types.rs index 3ca9f9d..7fc2207 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -140,7 +140,7 @@ pub struct Error { #[derive(Serialize, Deserialize, Debug, Default)] pub struct UnavailableGuild { id: String, - unavailable: Option + unavailable: Option, } /// See https://discord.com/developers/docs/resources/guild @@ -152,41 +152,71 @@ pub struct Guild { pub icon_hash: Option, pub splash: Option, pub discovery_splash: Option, - pub owner: Option, - pub owner_id: String, + pub owner: Option, + pub owner_id: Option, pub permissions: Option, pub afk_channel_id: Option, - pub afk_timeout: u8, + pub afk_timeout: Option, pub widget_enabled: Option, pub widget_channel_id: Option, - pub verification_level: u8, - pub default_message_notifications: u8, - pub explicit_content_filter: u8, + pub widget_channel: Option, + pub verification_level: Option, + pub default_message_notifications: Option, + pub explicit_content_filter: Option, pub roles: Vec, pub emojis: Vec, pub features: Vec, - pub mfa_level: u8, pub application_id: Option, pub system_channel_id: Option, - pub system_channel_flags: u8, + pub system_channel_flags: Option, pub rules_channel_id: Option, + pub rules_channel: Option, pub max_presences: Option, pub max_members: Option, pub vanity_url_code: Option, pub description: Option, pub banner: Option, - pub premium_tier: u8, + pub premium_tier: Option, pub premium_subscription_count: Option, - pub preferred_locale: String, + pub preferred_locale: Option, pub public_updates_channel_id: Option, + pub public_updates_channel: Option, pub max_video_channel_users: Option, pub max_stage_video_channel_users: Option, pub approximate_member_count: Option, pub approximate_presence_count: Option, + pub member_count: Option, + pub presence_count: Option, pub welcome_screen: Option, pub nsfw_level: u8, + pub nsfw: bool, pub stickers: Option>, - pub premium_progress_bar_enabled: bool + pub premium_progress_bar_enabled: Option, + pub joined_at: String, + pub afk_channel: Option, + pub bans: Option>, + pub primary_category_id: Option, + pub large: Option, + pub channels: Option>, + pub template_id: Option, + pub template: Option, + pub invites: Option>, + pub voice_states: Option>, + pub webhooks: Option>, + pub mfa_level: Option, + pub region: Option, + pub unavailable: bool, + pub parent: Option, +} + +/// See https://docs.spacebar.chat/routes/#get-/guilds/-guild_id-/bans/-user- +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct GuildBan { + pub id: String, + pub user_id: String, + pub guild_id: String, + pub executor_id: String, + pub reason: Option, } /// See https://discord.com/developers/docs/topics/gateway-events#guild-create-guild-create-extra-fields @@ -262,7 +292,7 @@ impl GuildCreateGuild { #[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct WelcomeScreenObject { pub description: Option, - pub welcome_channels: Vec + pub welcome_channels: Vec, } #[derive(Serialize, Deserialize, Debug, Default, Clone)] @@ -270,7 +300,7 @@ pub struct WelcomeScreenChannel { pub channel_id: String, pub description: String, pub emoji_id: Option, - pub emoji_name: Option + pub emoji_name: Option, } #[derive(Serialize, Deserialize, Debug, Default, Clone)] @@ -842,14 +872,14 @@ pub struct Integration { pub subscriber_count: Option, pub revoked: Option, pub application: Option, - pub scopes: Option> + pub scopes: Option>, } #[derive(Default, Debug, Deserialize, Serialize, Clone)] /// See https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure pub struct IntegrationAccount { pub id: String, - pub name: String + pub name: String, } #[derive(Default, Debug, Deserialize, Serialize, Clone)] @@ -879,7 +909,7 @@ pub struct StageInstance { pub topic: String, pub privacy_level: u8, pub discoverable_disabled: bool, - pub guild_scheduled_event_id: Option + pub guild_scheduled_event_id: Option, } #[derive(Debug, Deserialize, Serialize, Clone)] @@ -982,7 +1012,7 @@ pub struct PresenceUpdate { pub guild_id: String, pub status: String, pub activities: Vec, - pub client_status: ClientStatusObject + pub client_status: ClientStatusObject, } #[derive(Debug, Deserialize, Serialize, Default, Clone)] @@ -990,7 +1020,7 @@ pub struct PresenceUpdate { pub struct ClientStatusObject { pub desktop: Option, pub mobile: Option, - pub web: Option + pub web: Option, } impl WebSocketEvent for PresenceUpdate {} @@ -1178,7 +1208,7 @@ impl WebSocketEvent for GatewayHeartbeatAck {} pub struct ChannelPinsUpdate { pub guild_id: Option, pub channel_id: String, - pub last_pin_timestamp: Option> + pub last_pin_timestamp: Option>, } impl WebSocketEvent for ChannelPinsUpdate {} @@ -1270,7 +1300,7 @@ pub struct ThreadListSync { pub guild_id: String, pub channel_ids: Option>, pub threads: Vec, - pub members: Vec + pub members: Vec, } impl WebSocketEvent for ThreadListSync {} @@ -1294,7 +1324,7 @@ pub struct ThreadMembersUpdate { /// Capped at 50 pub member_count: u8, pub added_members: Option>, - pub removed_members: Option> + pub removed_members: Option>, } impl WebSocketEvent for ThreadMembersUpdate {} @@ -1304,13 +1334,13 @@ impl WebSocketEvent for ThreadMembersUpdate {} /// This one is particularly painful, it can be a Guild object with extra field or an unavailbile guild object pub struct GuildCreate { #[serde(flatten)] - pub d: GuildCreateDataOption + pub d: GuildCreateDataOption, } #[derive(Debug, Deserialize, Serialize)] pub enum GuildCreateDataOption { UnavailableGuild(UnavailableGuild), - Guild(Guild) + Guild(Guild), } impl Default for GuildCreateDataOption { @@ -1510,6 +1540,7 @@ impl PartialDiscordFileAttachment { proxy_url: self.proxy_url, height: self.height, width: self.width, + ephemeral: self.ephemeral, duration_secs: self.duration_secs, waveform: self.waveform, @@ -1563,3 +1594,91 @@ pub enum AllowedMentionType { pub struct Token { pub token: String, } + +/// See https://docs.spacebar.chat/routes/#cmp--schemas-template +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct GuildTemplate { + pub code: String, + pub name: String, + pub description: Option, + pub usage_count: Option, + pub creator_id: String, + pub creator: UserObject, + pub created_at: DateTime, + pub updated_at: DateTime, + pub source_guild_id: String, + pub source_guild: Vec, // Unsure how a {recursive: Guild} looks like, might be a Vec? + pub serialized_source_guild: Vec, + id: String, +} + +/// See https://docs.spacebar.chat/routes/#cmp--schemas-invite +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct GuildInvite { + pub code: String, + pub temporary: Option, + pub uses: Option, + pub max_uses: Option, + pub max_age: Option, + pub created_at: DateTime, + pub expires_at: Option>, + pub guild_id: String, + pub guild: Option, + pub channel_id: String, + pub channel: Option, + pub inviter_id: Option, + pub inviter: Option, + pub target_user_id: Option, + pub target_user: Option, + pub target_user_type: Option, + pub vanity_url: Option, +} + +/// See https://docs.spacebar.chat/routes/#cmp--schemas-voicestate +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct VoiceState { + pub guild_id: String, + pub guild: Option, + pub channel_id: String, + pub channel: Option, + pub user_id: String, + pub user: Option, + pub member: Option, + pub session_id: String, + pub token: String, + pub deaf: bool, + pub mute: bool, + pub self_deaf: bool, + pub self_mute: bool, + pub self_stream: Option, + pub self_video: bool, + pub suppress: bool, + pub request_to_speak_timestamp: Option>, + pub id: String, +} + +/// See https://docs.spacebar.chat/routes/#cmp--schemas-webhook +#[derive(Serialize, Deserialize, Debug, Default, Clone)] +pub struct Webhook { + #[serde(rename = "type")] + pub webhook_type: i32, + pub name: String, + pub avatar: String, + pub token: String, + pub guild_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub guild: Option, + pub channel_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub channel: Option, + pub application_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub application: Option, + pub user_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub user: Option, + pub source_guild_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_guild: Option, + pub id: String, +}