Compare commits

..

No commits in common. "a8b747f1ef4b9e85bbdd252f3ba0878b2d221dcf" and "ce67efe93cf5fa31edcf85c555c1fdbd7bdf2863" have entirely different histories.

22 changed files with 47 additions and 164 deletions

10
Cargo.lock generated
View File

@ -2314,8 +2314,9 @@ dependencies = [
[[package]] [[package]]
name = "sqlx-pg-uint" name = "sqlx-pg-uint"
version = "0.3.0" version = "0.2.0"
source = "git+https://github.com/bitfl0wer/sqlx-pg-uint#a132f4ad12f6cd1f68cc07e01edd644b4735e346" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "252a4a55217704777814f5be098ab5563d1e21c7f0d3010a301f75373d68c8e2"
dependencies = [ dependencies = [
"bigdecimal", "bigdecimal",
"serde", "serde",
@ -2326,8 +2327,9 @@ dependencies = [
[[package]] [[package]]
name = "sqlx-pg-uint-macros" name = "sqlx-pg-uint-macros"
version = "0.3.0" version = "0.2.0"
source = "git+https://github.com/bitfl0wer/sqlx-pg-uint#a132f4ad12f6cd1f68cc07e01edd644b4735e346" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe4f5704fe7b866782ab87d9fe069c2f02be27b801e990af56a3d94a29290bd8"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.75", "syn 2.0.75",

View File

@ -67,9 +67,7 @@ rand = "0.8.5"
flate2 = { version = "1.0.30", optional = true } flate2 = { version = "1.0.30", optional = true }
webpki-roots = "0.26.3" webpki-roots = "0.26.3"
pubserve = { version = "1.1.0", features = ["async", "send"] } pubserve = { version = "1.1.0", features = ["async", "send"] }
sqlx-pg-uint = { git = "https://github.com/bitfl0wer/sqlx-pg-uint", features = [ sqlx-pg-uint = { version = "0.2.0", optional = true }
"serde",
], optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustls = "0.21.12" rustls = "0.21.12"

View File

@ -40,7 +40,7 @@ impl Message {
chorus_request.deserialize_response::<Message>(user).await chorus_request.deserialize_response::<Message>(user).await
} else { } else {
for (index, attachment) in message.attachments.iter_mut().enumerate() { for (index, attachment) in message.attachments.iter_mut().enumerate() {
attachment.get_mut(index).unwrap().id = Some((index as u64).into()); attachment.get_mut(index).unwrap().id = Some(index as i16);
} }
let mut form = reqwest::multipart::Form::new(); let mut form = reqwest::multipart::Form::new();
let payload_json = to_string(&message).unwrap(); let payload_json = to_string(&message).unwrap();

View File

@ -224,8 +224,7 @@ pub struct ApplicationCommandOptionChoice {
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(i32)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// # Reference /// # Reference
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types> /// See <https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types>
pub enum ApplicationCommandOptionType { pub enum ApplicationCommandOptionType {
@ -295,8 +294,7 @@ pub struct ApplicationCommandPermission {
Ord, Ord,
)] )]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type> /// See <https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type>
pub enum ApplicationCommandPermissionType { pub enum ApplicationCommandPermissionType {
#[default] #[default]

View File

@ -48,10 +48,7 @@ pub struct Attachment {
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct PartialDiscordFileAttachment { pub struct PartialDiscordFileAttachment {
#[cfg(not(feature = "sqlx"))] pub id: Option<i16>,
pub id: Option<u64>,
#[cfg(feature = "sqlx")]
pub id: Option<PgU64>,
pub filename: String, pub filename: String,
/// Max 1024 characters /// Max 1024 characters
pub description: Option<String>, pub description: Option<String>,

View File

@ -110,8 +110,7 @@ pub struct AuditLogChange {
PartialOrd, PartialOrd,
Ord, Ord,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference: /// # Reference:
/// See <https://docs.discord.sex/resources/audit-log#audit-log-events> /// See <https://docs.discord.sex/resources/audit-log#audit-log-events>

View File

@ -32,8 +32,7 @@ pub struct AutoModerationRule {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types>
pub enum AutoModerationRuleEventType { pub enum AutoModerationRuleEventType {
@ -44,8 +43,7 @@ pub enum AutoModerationRuleEventType {
#[derive( #[derive(
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types>
pub enum AutoModerationRuleTriggerType { pub enum AutoModerationRuleTriggerType {
@ -82,22 +80,18 @@ pub struct AutoModerationRuleTriggerMetadataForKeywordPreset {
pub allow_list: Vec<String>, pub allow_list: Vec<String>,
} }
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] #[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy)]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata>
pub struct AutoModerationRuleTriggerMetadataForMentionSpam { pub struct AutoModerationRuleTriggerMetadataForMentionSpam {
/// Max 50 /// Max 50
#[cfg(not(feature = "sqlx"))]
pub mention_total_limit: u8, pub mention_total_limit: u8,
#[cfg(feature = "sqlx")]
pub mention_total_limit: sqlx_pg_uint::PgU8,
pub mention_raid_protection_enabled: bool, pub mention_raid_protection_enabled: bool,
} }
#[derive( #[derive(
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types>
pub enum AutoModerationRuleKeywordPresetType { pub enum AutoModerationRuleKeywordPresetType {
@ -116,20 +110,9 @@ pub struct AutoModerationAction {
} }
#[derive( #[derive(
Serialize_repr, Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Hash
Deserialize_repr,
Debug,
Clone,
Default,
PartialEq,
Eq,
PartialOrd,
Ord,
Copy,
Hash,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types>
pub enum AutoModerationActionType { pub enum AutoModerationActionType {

View File

@ -194,8 +194,7 @@ pub struct PermissionOverwrite {
} }
#[derive(Debug, Serialize_repr, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] #[derive(Debug, Serialize_repr, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// # Reference /// # Reference
/// ///
/// See <https://docs.discord.sex/resources/channel#permission-overwrite-type> /// See <https://docs.discord.sex/resources/channel#permission-overwrite-type>

View File

@ -32,6 +32,9 @@ use super::option_arc_rwlock_ptr_eq;
pub struct Emoji { pub struct Emoji {
pub id: Snowflake, pub id: Snowflake,
pub name: Option<String>, pub name: Option<String>,
#[cfg(feature = "sqlx")]
pub roles: Option<sqlx::types::Json<Vec<Snowflake>>>,
#[cfg(not(feature = "sqlx"))]
pub roles: Option<Vec<Snowflake>>, pub roles: Option<Vec<Snowflake>>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub user: Option<Shared<User>>, pub user: Option<Shared<User>>,

View File

@ -303,8 +303,7 @@ impl PartialEq for GuildScheduledEvent {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level>
pub enum GuildScheduledEventPrivacyLevel { pub enum GuildScheduledEventPrivacyLevel {
#[default] #[default]
@ -312,8 +311,7 @@ pub enum GuildScheduledEventPrivacyLevel {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status>
pub enum GuildScheduledEventStatus { pub enum GuildScheduledEventStatus {
#[default] #[default]
@ -336,8 +334,7 @@ pub enum GuildScheduledEventStatus {
Copy, Copy,
Hash, Hash,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types>
pub enum GuildScheduledEventEntityType { pub enum GuildScheduledEventEntityType {
#[default] #[default]
@ -375,8 +372,7 @@ pub struct VoiceRegion {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#message-notification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#message-notification-level>
pub enum MessageNotificationLevel { pub enum MessageNotificationLevel {
@ -399,8 +395,7 @@ pub enum MessageNotificationLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#explicit-content-filter-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#explicit-content-filter-level>
pub enum ExplicitContentFilterLevel { pub enum ExplicitContentFilterLevel {
@ -424,8 +419,7 @@ pub enum ExplicitContentFilterLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum VerificationLevel { pub enum VerificationLevel {
@ -451,8 +445,7 @@ pub enum VerificationLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum MFALevel { pub enum MFALevel {
@ -475,8 +468,7 @@ pub enum MFALevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum NSFWLevel { pub enum NSFWLevel {
@ -501,8 +493,7 @@ pub enum NSFWLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum PremiumTier { pub enum PremiumTier {

View File

@ -23,14 +23,8 @@ pub struct Integration {
pub syncing: Option<bool>, pub syncing: Option<bool>,
pub role_id: Option<String>, pub role_id: Option<String>,
pub enabled_emoticons: Option<bool>, pub enabled_emoticons: Option<bool>,
#[cfg(not(feature = "sqlx"))]
pub expire_behaviour: Option<u8>, pub expire_behaviour: Option<u8>,
#[cfg(feature = "sqlx")]
pub expire_behaviour: Option<sqlx_pg_uint::PgU8>,
#[cfg(not(feature = "sqlx"))]
pub expire_grace_period: Option<u16>, pub expire_grace_period: Option<u16>,
#[cfg(feature = "sqlx")]
pub expire_grace_period: Option<sqlx_pg_uint::PgU16>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub user: Option<Shared<User>>, pub user: Option<Shared<User>>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]

View File

@ -5,11 +5,8 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::{Snowflake, WelcomeScreenObject, Shared, InviteFlags, InviteType, InviteTargetType, Guild, VerificationLevel};
use crate::types::types::guild_configuration::GuildFeaturesList; use crate::types::types::guild_configuration::GuildFeaturesList;
use crate::types::{
Guild, InviteFlags, InviteTargetType, InviteType, Shared, Snowflake, VerificationLevel,
WelcomeScreenObject,
};
use super::guild::GuildScheduledEvent; use super::guild::GuildScheduledEvent;
use super::{Application, Channel, GuildMember, NSFWLevel, User}; use super::{Application, Channel, GuildMember, NSFWLevel, User};
@ -39,14 +36,8 @@ pub struct Invite {
pub invite_type: Option<InviteType>, pub invite_type: Option<InviteType>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub inviter: Option<User>, pub inviter: Option<User>,
#[cfg(not(feature = "sqlx"))]
pub max_age: Option<u32>, pub max_age: Option<u32>,
#[cfg(feature = "sqlx")]
pub max_age: Option<sqlx_pg_uint::PgU32>,
#[cfg(not(feature = "sqlx"))]
pub max_uses: Option<u8>, pub max_uses: Option<u8>,
#[cfg(feature = "sqlx")]
pub max_uses: Option<sqlx_pg_uint::PgU8>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub stage_instance: Option<InviteStageInstance>, pub stage_instance: Option<InviteStageInstance>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
@ -56,10 +47,7 @@ pub struct Invite {
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub target_user: Option<User>, pub target_user: Option<User>,
pub temporary: Option<bool>, pub temporary: Option<bool>,
#[cfg(not(feature = "sqlx"))]
pub uses: Option<u32>, pub uses: Option<u32>,
#[cfg(feature = "sqlx")]
pub uses: Option<sqlx_pg_uint::PgU32>,
} }
/// The guild an invite is for. /// The guild an invite is for.

View File

@ -150,10 +150,7 @@ pub enum MessageReferenceType {
pub struct MessageInteraction { pub struct MessageInteraction {
pub id: Snowflake, pub id: Snowflake,
#[serde(rename = "type")] #[serde(rename = "type")]
#[cfg(not(feature = "sqlx"))]
pub interaction_type: u8, pub interaction_type: u8,
#[cfg(feature = "sqlx")]
pub interaction_type: sqlx_pg_uint::PgU8,
pub name: String, pub name: String,
pub user: User, pub user: User,
pub member: Option<Shared<GuildMember>>, pub member: Option<Shared<GuildMember>>,
@ -285,14 +282,8 @@ pub struct EmbedField {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Reaction { pub struct Reaction {
#[cfg(not(feature = "sqlx"))]
pub count: u32, pub count: u32,
#[cfg(feature = "sqlx")]
pub count: sqlx_pg_uint::PgU32,
#[cfg(not(feature = "sqlx"))]
pub burst_count: u32, pub burst_count: u32,
#[cfg(feature = "sqlx")]
pub burst_count: sqlx_pg_uint::PgU32,
#[serde(default)] #[serde(default)]
pub me: bool, pub me: bool,
#[serde(default)] #[serde(default)]
@ -305,8 +296,6 @@ pub struct Reaction {
} }
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Ord)] #[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Ord)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum Component { pub enum Component {
ActionRow = 1, ActionRow = 1,
Button = 2, Button = 2,
@ -331,8 +320,7 @@ pub struct MessageActivity {
Debug, Default, PartialEq, Clone, Copy, Serialize_repr, Deserialize_repr, Eq, PartialOrd, Ord, Debug, Default, PartialEq, Clone, Copy, Serialize_repr, Deserialize_repr, Eq, PartialOrd, Ord,
)] )]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference /// # Reference
/// See <https://docs.discord.sex/resources/message#message-type> /// See <https://docs.discord.sex/resources/message#message-type>
@ -476,8 +464,7 @@ pub struct PartialEmoji {
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, Eq, Hash)] #[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, Eq, Hash)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum ReactionType { pub enum ReactionType {
Normal = 0, Normal = 0,
Burst = 1, // The dreaded super reactions Burst = 1, // The dreaded super reactions

View File

@ -45,8 +45,7 @@ impl PartialEq for Relationship {
Copy, Copy,
Hash, Hash,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord-userdoccers.vercel.app/resources/user#relationship-type> /// See <https://discord-userdoccers.vercel.app/resources/user#relationship-type>
pub enum RelationshipType { pub enum RelationshipType {
Suggestion = 6, Suggestion = 6,

View File

@ -32,10 +32,7 @@ pub struct RoleObject {
pub hoist: bool, pub hoist: bool,
pub icon: Option<String>, pub icon: Option<String>,
pub unicode_emoji: Option<String>, pub unicode_emoji: Option<String>,
#[cfg(not(feature = "sqlx"))]
pub position: u16, pub position: u16,
#[cfg(feature = "sqlx")]
pub position: sqlx_pg_uint::PgU16,
#[serde(default)] #[serde(default)]
pub permissions: PermissionFlags, pub permissions: PermissionFlags,
pub managed: bool, pub managed: bool,
@ -50,16 +47,11 @@ pub struct RoleObject {
pub struct RoleSubscriptionData { pub struct RoleSubscriptionData {
pub role_subscription_listing_id: Snowflake, pub role_subscription_listing_id: Snowflake,
pub tier_name: String, pub tier_name: String,
#[cfg(not(feature = "sqlx"))]
pub total_months_subscribed: u32, pub total_months_subscribed: u32,
#[cfg(feature = "sqlx")]
pub total_months_subscribed: sqlx_pg_uint::PgU32,
pub is_renewal: bool, pub is_renewal: bool,
} }
#[derive( #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, Hash, Copy, PartialOrd, Ord)]
Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, Hash, Copy, PartialOrd, Ord,
)]
/// See <https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure> /// See <https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure>
pub struct RoleTags { pub struct RoleTags {
#[serde(default)] #[serde(default)]

View File

@ -21,11 +21,8 @@ pub struct StageInstance {
pub guild_scheduled_event_id: Option<Snowflake>, pub guild_scheduled_event_id: Option<Snowflake>,
} }
#[derive( #[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord)]
Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, #[repr(u8)]
)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level> /// See <https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level>
pub enum StageInstancePrivacyLevel { pub enum StageInstancePrivacyLevel {

View File

@ -77,8 +77,7 @@ pub struct StickerItem {
#[derive( #[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename = "SCREAMING_SNAKE_CASE")] #[serde(rename = "SCREAMING_SNAKE_CASE")]
/// # Reference /// # Reference
@ -94,8 +93,7 @@ pub enum StickerType {
#[derive( #[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference /// # Reference
/// See <https://docs.discord.sex/resources/sticker#sticker-format-types> /// See <https://docs.discord.sex/resources/sticker#sticker-format-types>

View File

@ -34,10 +34,7 @@ impl PartialEq for Team {
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TeamMember { pub struct TeamMember {
#[cfg(not(feature = "sqlx"))]
pub membership_state: u8, pub membership_state: u8,
#[cfg(feature = "sqlx")]
pub membership_state: sqlx_pg_uint::PgU8,
pub permissions: Vec<String>, pub permissions: Vec<String>,
pub team_id: Snowflake, pub team_id: Snowflake,
pub user: Shared<User>, pub user: Shared<User>,

View File

@ -47,10 +47,7 @@ pub struct User {
pub bot: Option<bool>, pub bot: Option<bool>,
pub system: Option<bool>, pub system: Option<bool>,
pub mfa_enabled: Option<bool>, pub mfa_enabled: Option<bool>,
#[cfg(not(feature = "sqlx"))]
pub accent_color: Option<u32>, pub accent_color: Option<u32>,
#[cfg(feature = "sqlx")]
pub accent_color: Option<sqlx_pg_uint::PgU32>,
#[cfg_attr(feature = "sqlx", sqlx(default))] #[cfg_attr(feature = "sqlx", sqlx(default))]
pub locale: Option<String>, pub locale: Option<String>,
pub verified: Option<bool>, pub verified: Option<bool>,
@ -61,10 +58,7 @@ pub struct User {
#[serde(deserialize_with = "deserialize_option_number_from_string")] #[serde(deserialize_with = "deserialize_option_number_from_string")]
pub flags: Option<UserFlags>, pub flags: Option<UserFlags>,
pub premium_since: Option<DateTime<Utc>>, pub premium_since: Option<DateTime<Utc>>,
#[cfg(not(feature = "sqlx"))]
pub premium_type: Option<u8>, pub premium_type: Option<u8>,
#[cfg(feature = "sqlx")]
pub premium_type: Option<sqlx_pg_uint::PgU8>,
pub pronouns: Option<String>, pub pronouns: Option<String>,
pub public_flags: Option<UserFlags>, pub public_flags: Option<UserFlags>,
pub banner: Option<String>, pub banner: Option<String>,
@ -150,19 +144,13 @@ pub struct PublicUser {
pub username: Option<String>, pub username: Option<String>,
pub discriminator: Option<String>, pub discriminator: Option<String>,
pub avatar: Option<String>, pub avatar: Option<String>,
#[cfg(not(feature = "sqlx"))]
pub accent_color: Option<u32>, pub accent_color: Option<u32>,
#[cfg(feature = "sqlx")]
pub accent_color: Option<sqlx_pg_uint::PgU32>,
pub banner: Option<String>, pub banner: Option<String>,
pub theme_colors: Option<ThemeColors>, pub theme_colors: Option<ThemeColors>,
pub pronouns: Option<String>, pub pronouns: Option<String>,
pub bot: Option<bool>, pub bot: Option<bool>,
pub bio: Option<String>, pub bio: Option<String>,
#[cfg(not(feature = "sqlx"))]
pub premium_type: Option<u8>, pub premium_type: Option<u8>,
#[cfg(feature = "sqlx")]
pub premium_type: Option<sqlx_pg_uint::PgU8>,
pub premium_since: Option<DateTime<Utc>>, pub premium_since: Option<DateTime<Utc>>,
pub public_flags: Option<UserFlags>, pub public_flags: Option<UserFlags>,
} }

View File

@ -42,16 +42,10 @@ pub enum UserTheme {
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct UserSettings { pub struct UserSettings {
#[cfg(not(feature = "sqlx"))]
pub afk_timeout: Option<u16>, pub afk_timeout: Option<u16>,
#[cfg(feature = "sqlx")]
pub afk_timeout: Option<sqlx_pg_uint::PgU16>,
pub allow_accessibility_detection: bool, pub allow_accessibility_detection: bool,
pub animate_emoji: bool, pub animate_emoji: bool,
#[cfg(not(feature = "sqlx"))]
pub animate_stickers: u8, pub animate_stickers: u8,
#[cfg(feature = "sqlx")]
pub animate_stickers: sqlx_pg_uint::PgU8,
pub contact_sync_enabled: bool, pub contact_sync_enabled: bool,
pub convert_emoticons: bool, pub convert_emoticons: bool,
pub custom_status: Option<CustomStatus>, pub custom_status: Option<CustomStatus>,
@ -60,10 +54,7 @@ pub struct UserSettings {
pub developer_mode: bool, pub developer_mode: bool,
pub disable_games_tab: bool, pub disable_games_tab: bool,
pub enable_tts_command: bool, pub enable_tts_command: bool,
#[cfg(not(feature = "sqlx"))]
pub explicit_content_filter: u8, pub explicit_content_filter: u8,
#[cfg(feature = "sqlx")]
pub explicit_content_filter: sqlx_pg_uint::PgU8,
pub friend_source_flags: FriendSourceFlags, pub friend_source_flags: FriendSourceFlags,
pub gateway_connected: Option<bool>, pub gateway_connected: Option<bool>,
pub gif_auto_play: bool, pub gif_auto_play: bool,
@ -88,13 +79,10 @@ pub struct UserSettings {
impl Default for UserSettings { impl Default for UserSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
afk_timeout: Some(3600.into()), afk_timeout: Some(3600),
allow_accessibility_detection: true, allow_accessibility_detection: true,
animate_emoji: true, animate_emoji: true,
#[cfg(not(feature = "sqlx"))]
animate_stickers: 0, animate_stickers: 0,
#[cfg(feature = "sqlx")]
animate_stickers: 0.into(),
contact_sync_enabled: false, contact_sync_enabled: false,
convert_emoticons: false, convert_emoticons: false,
custom_status: None, custom_status: None,
@ -103,10 +91,7 @@ impl Default for UserSettings {
developer_mode: true, developer_mode: true,
disable_games_tab: true, disable_games_tab: true,
enable_tts_command: false, enable_tts_command: false,
#[cfg(not(feature = "sqlx"))]
explicit_content_filter: 0, explicit_content_filter: 0,
#[cfg(feature = "sqlx")]
explicit_content_filter: 0.into(),
friend_source_flags: Default::default(), friend_source_flags: Default::default(),
gateway_connected: Some(false), gateway_connected: Some(false),
gif_auto_play: false, gif_auto_play: false,
@ -140,7 +125,6 @@ pub struct CustomStatus {
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct FriendSourceFlags { pub struct FriendSourceFlags {
pub all: bool, pub all: bool,
} }
@ -152,12 +136,8 @@ impl Default for FriendSourceFlags {
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct GuildFolder { pub struct GuildFolder {
#[cfg(not(feature = "sqlx"))]
pub color: Option<u32>, pub color: Option<u32>,
#[cfg(feature = "sqlx")]
pub color: Option<sqlx_pg_uint::PgU32>,
pub guild_ids: Vec<String>, pub guild_ids: Vec<String>,
// FIXME: What is this thing? // FIXME: What is this thing?
// It's not a snowflake, and it's sometimes a string and sometimes an integer. // It's not a snowflake, and it's sometimes a string and sometimes an integer.

View File

@ -71,8 +71,7 @@ impl PartialEq for Webhook {
#[derive( #[derive(
Serialize, Deserialize, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
)] )]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
pub enum WebhookType { pub enum WebhookType {
#[default] #[default]

View File

@ -5,7 +5,7 @@
use bitflags::bitflags; use bitflags::bitflags;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::{entities::PermissionOverwrite, ChannelType, DefaultReaction, Snowflake}; use crate::types::{ChannelType, DefaultReaction, entities::PermissionOverwrite, Snowflake};
#[derive(Debug, Deserialize, Serialize, Default, PartialEq, PartialOrd)] #[derive(Debug, Deserialize, Serialize, Default, PartialEq, PartialOrd)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
@ -141,8 +141,7 @@ bitflags! {
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum InviteType { pub enum InviteType {
#[default] #[default]
Guild = 0, Guild = 0,
@ -153,8 +152,7 @@ pub enum InviteType {
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(not(feature = "sqlx"), repr(u8))] #[repr(u8)]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum InviteTargetType { pub enum InviteTargetType {
#[default] #[default]
Stream = 1, Stream = 1,
@ -171,9 +169,7 @@ pub struct AddChannelRecipientSchema {
} }
/// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient> /// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient>
#[derive( #[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash)]
Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash,
)]
pub struct ModifyChannelPositionsSchema { pub struct ModifyChannelPositionsSchema {
pub id: Snowflake, pub id: Snowflake,
pub position: Option<u32>, pub position: Option<u32>,
@ -182,9 +178,7 @@ pub struct ModifyChannelPositionsSchema {
} }
/// See <https://docs.discord.sex/resources/channel#follow-channel> /// See <https://docs.discord.sex/resources/channel#follow-channel>
#[derive( #[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash)]
Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash,
)]
pub struct AddFollowingChannelSchema { pub struct AddFollowingChannelSchema {
pub webhook_channel_id: Snowflake, pub webhook_channel_id: Snowflake,
} }