diff --git a/src/types/entities/application.rs b/src/types/entities/application.rs index 3ad0af2..9844e6d 100644 --- a/src/types/entities/application.rs +++ b/src/types/entities/application.rs @@ -22,9 +22,6 @@ pub struct Application { pub verify_key: String, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub owner: User, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub owner_id: Snowflake, pub flags: u64, #[cfg(feature = "sqlx")] pub redirect_uris: Option>>, @@ -38,11 +35,6 @@ pub struct Application { pub integration_require_code_grant: bool, pub discoverability_state: i64, pub discovery_eligibility_flags: i64, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub bot_user: Option, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub bot_user_id: Option, #[cfg(feature = "sqlx")] pub tags: Option>>, #[cfg(not(feature = "sqlx"))] @@ -56,9 +48,6 @@ pub struct Application { pub privacy_policy_url: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub team: Option, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub team_id: Option, } impl Application { diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index 89b2ebf..26b50a3 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -15,8 +15,6 @@ pub struct Attachment { pub proxy_url: String, pub height: Option, pub width: Option, - #[cfg(feature = "sqlx")] - pub message_id: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub message: Option, pub ephemeral: Option, diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 973023e..596bdbf 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -30,8 +30,9 @@ pub struct Channel { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub recipients: Option>, pub icon: Option, - pub owner_id: Option, - pub application_id: Option, + pub owner_id: Option, + pub application_id: Option, + pub managed: Option, pub parent_id: Option, pub last_pin_timestamp: Option, pub rtc_region: Option, diff --git a/src/types/entities/emoji.rs b/src/types/entities/emoji.rs index 01c4aca..0524d1b 100644 --- a/src/types/entities/emoji.rs +++ b/src/types/entities/emoji.rs @@ -12,14 +12,6 @@ pub struct Emoji { pub roles: Option>>, #[cfg(not(feature = "sqlx"))] pub roles: Option>, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub guild_id: Snowflake, - #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub guild: Guild, - #[cfg(feature = "sqlx")] - #[serde(skip)] - pub user_id: Option, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, pub require_colons: Option, diff --git a/src/types/entities/guild.rs b/src/types/entities/guild.rs index b2da5c1..1e73cc4 100644 --- a/src/types/entities/guild.rs +++ b/src/types/entities/guild.rs @@ -8,7 +8,8 @@ use crate::types::{ }; /// See https://discord.com/developers/docs/resources/guild -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Guild { pub id: Snowflake, pub name: String, @@ -16,24 +17,27 @@ pub struct Guild { pub icon_hash: Option, pub splash: Option, pub discovery_splash: Option, - pub owner: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub owner: bool, // True if requesting user is owner pub owner_id: Option, pub permissions: Option, pub afk_channel_id: Option, pub afk_timeout: Option, pub widget_enabled: Option, pub widget_channel_id: Option, - pub widget_channel: Option, pub verification_level: Option, pub default_message_notifications: Option, pub explicit_content_filter: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub roles: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub emojis: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub features: Vec, pub application_id: Option, pub system_channel_id: Option, pub system_channel_flags: Option, - pub rules_channel_id: Option, + pub rules_channel_id: Option, pub rules_channel: Option, pub max_presences: Option, pub max_members: Option, @@ -44,47 +48,48 @@ pub struct Guild { pub premium_subscription_count: Option, 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, + #[cfg(feature = "sqlx")] + pub welcome_screen: Option>, + #[cfg(not(feature = "sqlx"))] pub welcome_screen: Option, pub nsfw_level: u8, - pub nsfw: bool, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub stickers: Option>, pub premium_progress_bar_enabled: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub joined_at: String, - pub afk_channel: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub bans: Option>, pub primary_category_id: Option, pub large: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub channels: Option>, - pub template_id: Option, - pub template: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub invites: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub voice_states: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] 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)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildBan { - pub id: Snowflake, pub user_id: Snowflake, pub guild_id: Snowflake, - pub executor_id: Snowflake, pub reason: Option, } /// See https://docs.spacebar.chat/routes/#cmp--schemas-invite -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildInvite { pub code: String, pub temporary: Option, diff --git a/src/types/entities/integration.rs b/src/types/entities/integration.rs index d4ed911..8076e70 100644 --- a/src/types/entities/integration.rs +++ b/src/types/entities/integration.rs @@ -7,6 +7,7 @@ use crate::types::{ }; #[derive(Default, Debug, Deserialize, Serialize, Clone)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] /// See https://discord.com/developers/docs/resources/guild#integration-object-integration-structure pub struct Integration { pub id: Snowflake, @@ -19,11 +20,14 @@ pub struct Integration { pub enabled_emoticons: Option, pub expire_behaviour: Option, pub expire_grace_period: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub account: IntegrationAccount, pub synced_at: Option>, pub subscriber_count: Option, pub revoked: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub application: Option, pub scopes: Option>, } diff --git a/src/types/entities/message.rs b/src/types/entities/message.rs index e384e61..55cb92f 100644 --- a/src/types/entities/message.rs +++ b/src/types/entities/message.rs @@ -8,43 +8,62 @@ use crate::types::{ utils::Snowflake, }; -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Message { - id: Snowflake, + pub id: Snowflake, pub channel_id: Snowflake, - author: User, - content: String, - timestamp: String, - edited_timestamp: Option, - tts: bool, - mention_everyone: bool, - mentions: Vec, - mention_roles: Vec, - mention_channels: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub author: User, + pub content: String, + pub timestamp: String, + pub edited_timestamp: Option, + pub tts: bool, + pub mention_everyone: bool, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mentions: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mention_roles: Vec, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub mention_channels: Option>, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub attachments: Vec, - embeds: Vec, - reactions: Option>, - nonce: Option, - pinned: bool, - webhook_id: Option, + #[cfg(feature = "sqlx")] + pub embeds: Vec>, + #[cfg(not(feature = "sqlx"))] + pub embeds: Vec, + #[cfg(feature = "sqlx")] + pub reactions: Option>>, + #[cfg(not(feature = "sqlx"))] + pub reactions: Option>, + pub nonce: Option, + pub pinned: bool, + pub webhook_id: Option, #[serde(rename = "type")] - message_type: i32, - activity: Option, - application: Option, - application_id: Option, - message_reference: Option, - flags: Option, - referenced_message: Option>, - interaction: Option, - thread: Option, - components: Option>, - sticker_items: Option>, - stickers: Option>, - position: Option, - role_subscription_data: Option, + pub message_type: i32, + #[cfg(feature = "sqlx")] + pub activity: Option>, + #[cfg(not(feature = "sqlx"))] + pub activity: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] + pub application: Option, + pub application_id: Option, + #[cfg(feature = "sqlx")] + pub message_reference: Option>, + #[cfg(not(feature = "sqlx"))] + pub message_reference: Option, + pub flags: Option, + pub referenced_message: Option>, + pub interaction: Option, + pub thread: Option, + pub components: Option>, + pub sticker_items: Option>, + pub stickers: Option>, + pub position: Option, + pub role_subscription_data: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct MessageReference { pub message_id: Snowflake, pub channel_id: Snowflake, @@ -52,7 +71,7 @@ pub struct MessageReference { pub fail_if_not_exists: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] pub struct MessageInteraction { pub id: Snowflake, #[serde(rename = "type")] @@ -62,7 +81,7 @@ pub struct MessageInteraction { pub member: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct AllowedMention { parse: Vec, roles: Vec, @@ -70,7 +89,7 @@ pub struct AllowedMention { replied_user: bool, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum AllowedMentionType { Roles, @@ -78,16 +97,16 @@ pub enum AllowedMentionType { Everyone, } -#[derive(Debug, Serialize, Deserialize)] -struct ChannelMention { - id: Snowflake, - guild_id: Snowflake, +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ChannelMention { + pub id: Snowflake, + pub guild_id: Snowflake, #[serde(rename = "type")] channel_type: i32, name: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct Embed { title: Option, #[serde(rename = "type")] @@ -105,30 +124,30 @@ pub struct Embed { fields: Option>, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedFooter { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedFooter { text: String, icon_url: Option, proxy_icon_url: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedImage { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedImage { url: String, proxy_url: String, height: Option, width: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedThumbnail { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedThumbnail { url: String, proxy_url: Option, height: Option, width: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] struct EmbedVideo { url: Option, proxy_url: Option, @@ -136,29 +155,29 @@ struct EmbedVideo { width: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedProvider { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedProvider { name: Option, url: Option, } -#[derive(Debug, Serialize, Deserialize)] -struct EmbedAuthor { +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct EmbedAuthor { name: String, url: Option, icon_url: Option, proxy_icon_url: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -struct EmbedField { +pub struct EmbedField { name: String, value: String, inline: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct Reaction { pub count: i32, pub me: bool, @@ -177,7 +196,7 @@ pub enum Component { ChannelSelect = 8, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct MessageActivity { #[serde(rename = "type")] pub activity_type: i64, diff --git a/src/types/entities/role.rs b/src/types/entities/role.rs index 708be00..f427dc9 100644 --- a/src/types/entities/role.rs +++ b/src/types/entities/role.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] /// See https://discord.com/developers/docs/topics/permissions#role-object pub struct RoleObject { pub id: Snowflake, @@ -19,7 +20,7 @@ pub struct RoleObject { //pub tags: Option } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct RoleSubscriptionData { pub role_subscription_listing_id: Snowflake, pub tier_name: String, diff --git a/src/types/entities/security_key.rs b/src/types/entities/security_key.rs index 09112cc..2cf8f66 100644 --- a/src/types/entities/security_key.rs +++ b/src/types/entities/security_key.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct SecurityKey { pub id: String, pub user_id: String, diff --git a/src/types/entities/sticker.rs b/src/types/entities/sticker.rs index d8f2803..3c4a9d2 100644 --- a/src/types/entities/sticker.rs +++ b/src/types/entities/sticker.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::types::{entities::User, utils::Snowflake}; -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Sticker { pub id: Snowflake, pub pack_id: Option, @@ -14,12 +15,13 @@ pub struct Sticker { pub sticker_type: u8, pub format_type: u8, pub available: Option, - pub guild_id: Option, + pub guild_id: Option, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, pub sort_value: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct StickerItem { pub id: Snowflake, pub name: String, diff --git a/src/types/entities/team.rs b/src/types/entities/team.rs index 7c381a6..a6f2ef1 100644 --- a/src/types/entities/team.rs +++ b/src/types/entities/team.rs @@ -1,20 +1,23 @@ use serde::{Deserialize, Serialize}; use crate::types::entities::User; +use crate::types::Snowflake; -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Team { pub icon: Option, - pub id: u64, + pub id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub members: Vec, pub name: String, - pub owner_user_id: u64, + pub owner_user_id: Snowflake, } -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] pub struct TeamMember { pub membership_state: u8, pub permissions: Vec, - pub team_id: u64, + pub team_id: Snowflake, pub user: User, } diff --git a/src/types/entities/template.rs b/src/types/entities/template.rs index dfbd98a..aa87251 100644 --- a/src/types/entities/template.rs +++ b/src/types/entities/template.rs @@ -7,18 +7,21 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-template -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct GuildTemplate { pub code: String, pub name: String, pub description: Option, pub usage_count: Option, pub creator_id: Snowflake, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub creator: User, pub created_at: DateTime, pub updated_at: DateTime, pub source_guild_id: String, + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub source_guild: Vec, // Unsure how a {recursive: Guild} looks like, might be a Vec? + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub serialized_source_guild: Vec, - id: Snowflake, } diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index 1c8b102..ee3702d 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -1,8 +1,6 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; -#[cfg(feature = "sqlx")] -use sqlx::{FromRow, Type}; use crate::types::{ errors::Error, @@ -10,7 +8,7 @@ use crate::types::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] -#[cfg_attr(feature = "sqlx", derive(Type))] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] pub struct UserData { pub valid_tokens_since: DateTime, pub hash: Option, @@ -23,32 +21,34 @@ impl User { } #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct User { pub id: Snowflake, - username: String, - discriminator: String, - avatar: Option, - bot: bool, - system: Option, - mfa_enabled: Option, - accent_color: Option, - locale: Option, - verified: Option, - email: Option, - flags: String, - premium_since: Option>, - premium_type: u8, - pronouns: Option, - public_flags: Option, - banner: Option, - bio: String, - theme_colors: Option>, - phone: Option, - nsfw_allowed: bool, - premium: bool, - purchased_flags: i32, - premium_usage_flags: i32, - disabled: Option, + pub username: String, + pub discriminator: String, + pub avatar: Option, + pub bot: bool, + pub system: Option, + pub mfa_enabled: Option, + pub accent_color: Option, + #[cfg_attr(feature = "sqlx", sqlx(default))] + pub locale: Option, + pub verified: Option, + pub email: Option, + pub flags: String, + pub premium_since: Option>, + pub premium_type: u8, + pub pronouns: Option, + pub public_flags: Option, + pub banner: Option, + pub bio: String, + pub theme_colors: Option>, + pub phone: Option, + pub nsfw_allowed: bool, + pub premium: bool, + pub purchased_flags: i32, + pub premium_usage_flags: i32, + pub disabled: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -92,7 +92,7 @@ const CUSTOM_USER_FLAG_OFFSET: u64 = 1 << 32; bitflags::bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] - #[cfg_attr(feature = "sqlx", derive(Type))] + #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] pub struct UserFlags: u64 { const DISCORD_EMPLOYEE = 1 << 0; const PARTNERED_SERVER_OWNER = 1 << 1; diff --git a/src/types/entities/user_settings.rs b/src/types/entities/user_settings.rs index 6f3ac53..1445c31 100644 --- a/src/types/entities/user_settings.rs +++ b/src/types/entities/user_settings.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::types::utils::Snowflake; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "lowercase")] pub enum UserStatus { #[default] @@ -23,6 +24,7 @@ pub enum UserTheme { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct UserSettings { pub afk_timeout: u16, pub allow_accessibility_detection: bool, @@ -30,6 +32,9 @@ pub struct UserSettings { pub animate_stickers: u8, pub contact_sync_enabled: bool, pub convert_emoticons: bool, + #[cfg(feature = "sqlx")] + pub custom_status: Option>, + #[cfg(not(feature = "sqlx"))] pub custom_status: Option, pub default_guilds_restricted: bool, pub detect_platform_accounts: bool, @@ -37,10 +42,19 @@ pub struct UserSettings { pub disable_games_tab: bool, pub enable_tts_command: bool, pub explicit_content_filter: u8, + #[cfg(feature = "sqlx")] + pub friend_source_flags: sqlx::types::Json, + #[cfg(not(feature = "sqlx"))] pub friend_source_flags: FriendSourceFlags, pub gateway_connected: bool, pub gif_auto_play: bool, + #[cfg(feature = "sqlx")] + pub guild_folders: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub guild_folders: Vec, + #[cfg(feature = "sqlx")] + pub guild_positions: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub guild_positions: Vec, pub inline_attachment_media: bool, pub inline_embed_media: bool, @@ -49,6 +63,9 @@ pub struct UserSettings { pub native_phone_integration_enabled: bool, pub render_embeds: bool, pub render_reactions: bool, + #[cfg(feature = "sqlx")] + pub restricted_guilds: sqlx::types::Json>, + #[cfg(not(feature = "sqlx"))] pub restricted_guilds: Vec, pub show_current_game: bool, pub status: UserStatus, @@ -73,11 +90,11 @@ impl Default for UserSettings { disable_games_tab: true, enable_tts_command: false, explicit_content_filter: 0, - friend_source_flags: FriendSourceFlags::default(), + friend_source_flags: Default::default(), gateway_connected: false, gif_auto_play: false, - guild_folders: Vec::new(), - guild_positions: Vec::new(), + guild_folders: Default::default(), + guild_positions: Default::default(), inline_attachment_media: true, inline_embed_media: true, locale: "en-US".to_string(), @@ -85,7 +102,7 @@ impl Default for UserSettings { native_phone_integration_enabled: true, render_embeds: true, render_reactions: true, - restricted_guilds: Vec::new(), + restricted_guilds: Default::default(), show_current_game: true, status: UserStatus::Online, stream_notifications_enabled: false, @@ -96,6 +113,7 @@ impl Default for UserSettings { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct CustomStatus { pub emoji_id: Option, pub emoji_name: Option, diff --git a/src/types/entities/voice_state.rs b/src/types/entities/voice_state.rs index 68e2051..fd81ba8 100644 --- a/src/types/entities/voice_state.rs +++ b/src/types/entities/voice_state.rs @@ -7,17 +7,14 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-voicestate -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct VoiceState { pub guild_id: Snowflake, - pub guild: Option, pub channel_id: Snowflake, - pub channel: Option, pub user_id: Snowflake, - pub user: Option, pub member: Option, pub session_id: Snowflake, - pub token: String, pub deaf: bool, pub mute: bool, pub self_deaf: bool, @@ -26,5 +23,4 @@ pub struct VoiceState { pub self_video: bool, pub suppress: bool, pub request_to_speak_timestamp: Option>, - pub id: Snowflake, } diff --git a/src/types/entities/webhook.rs b/src/types/entities/webhook.rs index 26fa81f..0097d81 100644 --- a/src/types/entities/webhook.rs +++ b/src/types/entities/webhook.rs @@ -6,27 +6,24 @@ use crate::types::{ }; /// See https://docs.spacebar.chat/routes/#cmp--schemas-webhook -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] pub struct Webhook { + pub id: Snowflake, #[serde(rename = "type")] pub webhook_type: i32, pub name: String, pub avatar: String, pub token: String, pub guild_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] - pub guild: Option, pub channel_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] - pub channel: Option, pub application_id: Snowflake, #[serde(skip_serializing_if = "Option::is_none")] - pub application: Option, - pub user_id: Snowflake, - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub user: Option, - pub source_guild_id: Snowflake, #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "sqlx", sqlx(skip))] pub source_guild: Option, - pub id: Snowflake, + #[serde(skip_serializing_if = "Option::is_none")] + pub url: Option, } diff --git a/src/types/interfaces/guild_welcome_screen.rs b/src/types/interfaces/guild_welcome_screen.rs index f799b1d..0260ab3 100644 --- a/src/types/interfaces/guild_welcome_screen.rs +++ b/src/types/interfaces/guild_welcome_screen.rs @@ -1,14 +1,14 @@ use crate::types::utils::Snowflake; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct WelcomeScreenObject { pub enabled: bool, pub description: Option, pub welcome_channels: Vec, } -#[derive(Serialize, Deserialize, Debug, Default, Clone)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct WelcomeScreenChannel { pub channel_id: Snowflake, pub description: String,