From: n1c00o Date: Mon, 4 Oct 2021 18:24:16 +0000 (+0200) Subject: Add structures X-Git-Tag: v0.1~55^2~8 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=11c7478a0597609006df55610f08796ac7709c4e;p=matthieu%2Fnova.git Add structures --- diff --git a/common/rust/src/discord_models/audit_log.rs b/common/rust/src/discord_models/audit_log.rs new file mode 100644 index 0000000..ad63277 --- /dev/null +++ b/common/rust/src/discord_models/audit_log.rs @@ -0,0 +1,208 @@ +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::{guild::Integration, user::User, webhook::Webhook}; + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum AuditLogEvents { + GuildUpdate = 1, + ChannelCreate = 10, + ChannelUpdate = 11, + ChannelDelete = 12, + ChannelOverwriteCreate = 13, + ChannelOverwriteUpdate = 14, + ChannelOverwriteDelete = 15, + MemberKick = 20, + MemberPrune = 21, + MemberBanAdd = 22, + MemberBanRemove = 23, + MemberUpdate = 24, + MemberRoleUpdate = 25, + MemberMove = 26, + MemberDisconnect = 27, + BotAdd = 28, + RoleCreate = 30, + RoleUpdate = 31, + RoleDelete = 32, + InviteCreate = 40, + InviteUpdate = 41, + InviteDelete = 42, + WebhookCreate = 50, + WebhookUpdate = 51, + WebhookDelete = 52, + EmojiCreate = 60, + EmojiUpdate = 61, + EmojiDelete = 62, + MessageDelete = 72, + MessageBulkDelete = 73, + MessagePin = 74, + MessageUnpin = 75, + IntegrationCreate = 80, + IntegrationUpdate = 81, + IntegrationDelete = 82, + StageInstanceCreate = 83, + StageInstanceUpdate = 84, + StageInstanceDelete = 85, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum OptionalAuditEntryInfoType { + #[serde(rename = "0")] + Role, + #[serde(rename = "1")] + Member, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct OptionalAuditEntryInfo { + pub delete_member_days: Option, + pub members_removed: Option, + pub channel_id: Option, + pub message_id: Option, + pub count: Option, + pub id: Option, + #[serde(rename = "type")] + pub type_: Option, + pub role_name: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum AuditLogChangeKey { + #[serde(rename = "name")] + Name, + #[serde(rename = "description")] + Description, + #[serde(rename = "icon_hash")] + IconHash, + #[serde(rename = "splash_hash")] + SplashHash, + #[serde(rename = "discovery_splash_hash")] + DiscoverySplashHash, + #[serde(rename = "banner_hash")] + BannerHash, + #[serde(rename = "owner_id")] + OwnerId, + #[serde(rename = "region")] + Region, + #[serde(rename = "preferred_locale")] + PreferredLocale, + #[serde(rename = "afk_channel_id")] + AfkChannelId, + #[serde(rename = "afk_timeout")] + AfkTimeout, + #[serde(rename = "rules_channel_id")] + RulesChannelId, + #[serde(rename = "public_updates_channel_id")] + PublicUpdatesChannelId, + #[serde(rename = "mfa_level")] + MfaLevel, + #[serde(rename = "verification_level")] + VerificationLevel, + #[serde(rename = "explicit_content_filter")] + ExplicitContentFilter, + #[serde(rename = "default_message_notifications")] + DefaultMessageNotifications, + #[serde(rename = "vanity_url_code")] + VanityUrlCode, + #[serde(rename = "$add")] + Add, + #[serde(rename = "$remove")] + Remove, + #[serde(rename = "prune_delete_days")] + PruneDeleteDays, + #[serde(rename = "widget_enabled")] + WidgetEnabled, + #[serde(rename = "widget_channel_id")] + WidgetChannelId, + #[serde(rename = "system_channel_id")] + SystemChannelId, + #[serde(rename = "position")] + Position, + #[serde(rename = "topic")] + Topic, + #[serde(rename = "bitrate")] + Bitrate, + #[serde(rename = "permission_overwrites")] + PermissionOverwrites, + #[serde(rename = "nsfw")] + Nsfw, + #[serde(rename = "application_id")] + ApplicationId, + #[serde(rename = "rate_limit_per_user")] + RateLimitPerUser, + #[serde(rename = "permissions")] + Permissions, + #[serde(rename = "color")] + Color, + #[serde(rename = "hoist")] + Hoist, + #[serde(rename = "mentionable")] + Mentionable, + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + #[serde(rename = "code")] + Code, + #[serde(rename = "channel_id")] + ChannelId, + #[serde(rename = "inviter_id")] + InviterId, + #[serde(rename = "max_uses")] + MaxUses, + #[serde(rename = "uses")] + Uses, + #[serde(rename = "max_age")] + MaxAge, + #[serde(rename = "temporary")] + Temporary, + #[serde(rename = "deaf")] + Deaf, + #[serde(rename = "mute")] + Mute, + #[serde(rename = "nick")] + Nick, + #[serde(rename = "avatar_hash")] + AvatarHash, + #[serde(rename = "id")] + Id, + #[serde(rename = "type")] + Type, + #[serde(rename = "enable_emoticons")] + EnableEmoticons, + #[serde(rename = "expire_behavior")] + ExpireBehavior, + #[serde(rename = "expire_grace_period")] + ExpireGracePeriod, + #[serde(rename = "user_limit")] + UserLimit, + #[serde(rename = "privacy_level")] + PrivacyLevel, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct AuditLogChange { + pub new_value: Option, + pub old_value: Option, + pub key: AuditLogChangeKey, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct AuditLogEntry { + pub target_id: Option, + pub changes: Option>, + pub user_id: Option, + pub id: String, + pub action_type: AuditLogEvents, + pub options: Option, + pub reason: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct AuditLog { + pub webhooks: Vec, + pub users: Vec, + pub audit_log_entries: Vec, + pub integrations: Vec, +} diff --git a/common/rust/src/discord_models/channel.rs b/common/rust/src/discord_models/channel.rs index 41f4a4b..980960b 100644 --- a/common/rust/src/discord_models/channel.rs +++ b/common/rust/src/discord_models/channel.rs @@ -1,7 +1,11 @@ +use enumflags2::{bitflags, BitFlags}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use super::user::User; +use super::{ + application::Application, emoji::Emoji, guild::GuildMember, message_components::Component, + slash_commands::MessageInteraction, user::User, +}; #[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] #[repr(u8)] @@ -87,3 +91,251 @@ pub struct Channel { pub member: Option, pub default_auto_archive_duration: Option, } + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Attachment { + pub id: String, + pub filename: String, + pub content_type: String, + pub size: i64, + pub url: String, + pub proxy_url: String, + pub height: Option, + pub width: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ChannelMention { + pub id: String, + pub guild_id: String, + #[serde(rename = "type")] + pub type_: ChannelTypes, + pub name: String, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum EmbedTypes { + #[serde(rename = "rich")] + Rich, + #[serde(rename = "image")] + Image, + #[serde(rename = "video")] + Video, + #[serde(rename = "gifv")] + Gifv, + #[serde(rename = "article")] + Article, + #[serde(rename = "link")] + Link, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedThumbnail { + pub url: Option, + pub proxy_url: Option, + pub height: Option, + pub width: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedVideo { + pub url: Option, + pub proxy_url: Option, + pub height: Option, + pub width: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedImage { + pub url: Option, + pub proxy_url: Option, + pub height: Option, + pub width: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedProvider { + pub name: Option, + pub url: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedAuthor { + pub name: Option, + pub url: Option, + pub icon_url: Option, + pub proxy_icon_url: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedFooter { + pub text: String, + pub icon_url: Option, + pub proxy_icon_url: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct EmbedField { + pub name: String, + pub value: String, + pub inline: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Embed { + pub title: Option, + #[serde(rename = "type")] + pub type_: Option, + pub description: Option, + pub url: Option, + pub timestamp: Option, + pub color: Option, + pub footer: Option, + pub image: Option, + pub thumbnail: Option, + pub video: Option, + pub provider: Option, + pub author: Option, + pub fields: Option>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Reaction { + pub count: i64, + pub me: bool, + pub emoji: Emoji, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum MessageTypes { + Default = 0, + RecipientAdd = 1, + RecipientRemove = 2, + Call = 3, + ChannelNameChange = 4, + ChannelIconChange = 5, + ChannelPinnedMessage = 6, + GuildMemberJoin = 7, + UserPremiumGuildSubscription = 8, + UserPremiumGuildSubscriptionTier1 = 9, + UserPremiumGuildSubscriptionTier2 = 10, + UserPremiumGuildSubscriptionTier3 = 11, + ChannelFollowAdd = 12, + GuildDiscoveryDisqualified = 14, + GuildDiscoveryRequalified = 15, + GuildDiscoveryGracePeriodInitialWarning = 16, + GuildDiscoveryGracePeriodFinalWarning = 17, + ThreadCreated = 18, + Reply = 20, + ApplicationCommand = 20, + ThreadStarterMessage = 21, + GuildInviteReminder = 22, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum MessageActivityTypes { + Join = 1, + Spectate = 2, + Listen = 3, + JoinRequest = 5, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MessageActivity { + #[serde(rename = "type")] + pub type_: MessageActivityTypes, + pub party_id: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MessageReference { + pub message_id: Option, + pub channel_id: Option, + pub guild_id: Option, + pub fail_if_not_exists: Option, +} + +#[bitflags] +#[repr(u64)] +#[derive(Debug, Clone, Copy)] +pub enum MessageFlags { + Crossposted = 1 << 0, + IsCrosspost = 1 << 1, + SuppressEmbeds = 1 << 2, + SourceMessageDeleted = 1 << 3, + Urgent = 1 << 4, + HasThread = 1 << 5, + Ephemeral = 1 << 6, + Loading = 1 << 7, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum MessageStickerFormatTypes { + Png = 1, + Apng = 2, + Lottie = 3, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MessageStickerItem { + pub id: String, + pub name: String, + pub format_type: MessageStickerFormatTypes, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MessageSticker { + pub id: String, + pub pack_id: Option, + pub name: String, + pub description: String, + pub tags: String, + // deprecated + // pub asset: String, + pub format_type: MessageStickerFormatTypes, + pub available: Option, + pub guild_id: Option, + pub user: Option, + pub sort_value: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Message { + pub id: String, + pub channel_id: String, + pub guild_id: Option, + pub author: User, + pub member: Option, + pub content: String, + pub timestamp: String, + pub edited_timestamp: String, + pub tts: bool, + pub mention_everyone: bool, + pub mentions: Vec, // todo: It is a Vector of User objects, with an additional partial member field (GuildMember) + pub mentions_roles: Vec, + pub mention_channels: Option>, + pub attachments: Vec, + pub embeds: Vec, + pub reactions: Option>, + /// ! Can be a String or an int ! + pub nonce: Option, + pub pinned: bool, + pub webhook_id: Option, + #[serde(rename = "type")] + pub type_: MessageTypes, + pub activity: Option, + pub application: Option, + pub application_id: Option, + pub message_reference: Option, + pub flags: Option>, + pub referenced_message: Option, + pub interaction: Option, + pub thread: Option, + pub components: Option, + pub sticker_items: Option>, + // deprecated + // pub stickers: Option>, +} diff --git a/common/rust/src/discord_models/emoji.rs b/common/rust/src/discord_models/emoji.rs new file mode 100644 index 0000000..eec02e7 --- /dev/null +++ b/common/rust/src/discord_models/emoji.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use super::user::User; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Emoji { + pub id: Option, + pub name: Option, + pub roles: Vec, + pub user: Option, + pub require_colons: Option, + pub managed: Option, + pub animated: Option, + pub available: Option, +} diff --git a/common/rust/src/discord_models/gateway.rs b/common/rust/src/discord_models/gateway.rs new file mode 100644 index 0000000..dbdf60d --- /dev/null +++ b/common/rust/src/discord_models/gateway.rs @@ -0,0 +1,118 @@ +use enumflags2::{bitflags, BitFlags}; +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::user::User; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum PresenceUpdateStatus { + #[serde(rename = "online")] + Online, + #[serde(rename = "idle")] + Idle, + #[serde(rename = "dnd")] + Dnd, + #[serde(rename = "offline")] + Offline, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ClientStatus { + pub desktop: Option, + pub mobile: Option, + pub web: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct PresenceUpdate { + pub user: User, + pub guild_id: String, + pub status: PresenceUpdateStatus, + pub activities: Vec, + pub client_status: ClientStatus, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ActivityTypes { + Game = 0, + Streaming = 1, + Listening = 2, + Watching = 3, + Custom = 4, + Competing = 5, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivityTimestamps { + pub start: Option, + pub end: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivityEmoji { + pub name: String, + pub id: Option, + pub animated: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivityParty { + pub id: Option, + /// [current_size, max_size] + pub size: Option>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivityAssets { + pub large_image: Option, + pub large_text: Option, + pub small_image: Option, + pub small_text: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivitySecrets { + pub join: Option, + pub spectate: Option, + #[serde(rename = "match")] + pub match_: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ActivityButtons { + pub label: String, + pub url: String, +} + +#[bitflags] +#[repr(u64)] +#[derive(Debug, Clone, Copy)] +pub enum ActivityFlags { + Instance = 1 << 0, + Join = 1 << 1, + Spectate = 1 << 2, + JoinRequest = 1 << 3, + Sync = 1 << 4, + Play = 1 << 5, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Activity { + pub name: String, + #[serde(rename = "type")] + pub type_: ActivityTypes, + pub url: Option, + pub created_at: String, + pub timestamps: Option, + pub application_id: Option, + pub details: Option, + pub state: Option, + pub emoji: Option, + pub party: Option, + pub assets: Option, + pub secrets: Option, + pub instance: Option, + pub flags: Option>, + pub buttons: Option>, +} diff --git a/common/rust/src/discord_models/guild.rs b/common/rust/src/discord_models/guild.rs index 92a11e7..85da5b2 100644 --- a/common/rust/src/discord_models/guild.rs +++ b/common/rust/src/discord_models/guild.rs @@ -1,7 +1,11 @@ +use enumflags2::{bitflags, BitFlags}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use super::user::User; +use super::{ + channel::Channel, emoji::Emoji, gateway::PresenceUpdate, permissions::Role, + stage_instance::StageInstance, user::User, voice::VoiceState, +}; #[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] #[repr(u8)] @@ -45,3 +49,207 @@ pub struct Integration { pub revoked: Option, pub application: Option, } + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum VerificationLevel { + None = 0, + Low = 1, + Medium = 2, + High = 3, + VeryHigh = 4, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum PremiumTier { + None = 0, + Tier1 = 1, + Tier2 = 2, + Tier3 = 3, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ExplicitContentFilter { + Disabled = 0, + MembersWithoutRoles = 1, + AllMembers = 2, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum MfaLevel { + None = 0, + Elevated = 1, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum DefaultMessageNotificationLevel { + AllMessages = 0, + OnlyMentions = 1, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum GuildNsfwLevel { + Default = 0, + Explicit = 1, + Safe = 2, + AgeRestricted = 3, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum GuildFeatures { + #[serde(rename = "ANIMATED_ICON")] + AnimatedIcon, + #[serde(rename = "BANNER")] + Banner, + #[serde(rename = "COMMERCE")] + Commerce, + #[serde(rename = "COMMUNITY")] + Community, + #[serde(rename = "DISCOVERABLE")] + Discoverable, + #[serde(rename = "FEATURABLE")] + Featurable, + #[serde(rename = "INVITE_SPLASH")] + InviteSplash, + #[serde(rename = "MEMBER_VERIFICATION_GATE_ENABLED")] + MemberVerificationGateEnabled, + #[serde(rename = "NEWS")] + News, + #[serde(rename = "PARTNERED")] + Partnered, + #[serde(rename = "PREVIEW_ENABLED")] + PreviewEnabled, + #[serde(rename = "VANITY_URL")] + VanityUrl, + #[serde(rename = "VERIFIED")] + Verified, + #[serde(rename = "VIP_REGIONS")] + VipRegions, + #[serde(rename = "WELCOME_SCREEN_ENABLED")] + WelcomeScreenEnabled, + #[serde(rename = "TICKETED_EVENTS_ENABLED")] + TicketedEventsEnabled, + #[serde(rename = "MONETIZATION_ENABLED")] + MonetizationEnabled, + #[serde(rename = "MORE_STICKERS")] + MoreStickers, + #[serde(rename = "THREE_DAY_THREAD_ARCHIVE")] + ThreeDayThreadArchive, + #[serde(rename = "SEVEN_DAY_THREAD_ARCHIVE")] + SevenDayThreadArchive, + #[serde(rename = "PRIVATE_THREADS")] + PrivateThreads, +} + +#[bitflags] +#[repr(u64)] +#[derive(Debug, Clone, Copy)] +pub enum SystemChannelFlags { + SuppressJoinNotifications = 1 << 0, + SuppressPremiumSubscriptions = 1 << 1, + SuppressGuildReminderNotifications = 1 << 2, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct WelcomeScreenChannel { + pub channel_id: String, + pub description: String, + pub emoji_id: Option, + pub emoji_name: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct WelcomeScreen { + pub description: String, + pub welcome_channels: Vec, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Guild { + pub id: String, + pub name: String, + pub icon: Option, + pub icon_hash: Option, + pub splash: Option, + pub discovery_splash: Option, + pub owner: Option, + pub owner_id: String, + pub permissions: Option, + /// DEPRECATED + pub region: Option, + pub afk_channel_id: Option, + pub afk_timeout: i64, + pub widget_enabled: Option, + pub widget_channel_id: Option, + pub verification_level: VerificationLevel, + pub default_message_notifications: DefaultMessageNotificationLevel, + pub explicit_content_filter: ExplicitContentFilter, + pub roles: Vec, + pub emojis: Vec, + pub features: Vec, + pub mfa_level: MfaLevel, + pub application_id: Option, + pub system_channel_id: Option, + pub system_channel_flags: BitFlags, + pub rules_channel_id: Option, + pub joined_at: Option, + pub large: Option, + pub unavailable: Option, + pub member_count: Option, + pub voice_states: Option>, + pub members: Option>, + pub channels: Option>, + pub threads: Option>, + pub presences: Option>, + pub max_presences: Option, + pub vanity_url_code: Option, + pub description: Option, + pub banner: Option, + pub premium_tier: PremiumTier, + pub premium_subscription_count: i64, + pub preferred_locale: String, + pub public_updates_channel_id: Option, + pub max_video_channel_users: Option, + pub approximate_member_count: Option, + pub welcome_screen: Option, + pub nsfw_level: GuildNsfwLevel, + pub stage_instances: Option>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GuildMember { + pub user: Option, + pub nick: Option, + pub roles: Vec, + pub joined_at: String, + pub premium_since: Option, + pub deaf: bool, + pub mute: bool, + pub pending: Option, + pub permissions: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GuildPreview { + pub id: String, + pub name: String, + pub icon: Option, + pub splash: Option, + pub discovery_splash: Option, + pub emojis: Vec, + pub features: Vec, + pub approximate_member_count: i64, + pub approximate_presence_count: i64, + pub description: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GuildWidget { + pub enabled: bool, + pub channel_id: Option, +} diff --git a/common/rust/src/discord_models/guild_template.rs b/common/rust/src/discord_models/guild_template.rs new file mode 100644 index 0000000..960631d --- /dev/null +++ b/common/rust/src/discord_models/guild_template.rs @@ -0,0 +1,18 @@ +use serde::{Deserialize, Serialize}; + +use super::{guild::Guild, user::User}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GuildTemplate { + pub code: String, + pub name: String, + pub description: Option, + pub usage_count: i64, + pub creator_id: String, + pub creator: User, + pub created_at: String, + pub updated_at: String, + pub source_guild_ild: String, + pub serialized_source_guild: Guild, + pub is_dirty: Option, +} diff --git a/common/rust/src/discord_models/invite.rs b/common/rust/src/discord_models/invite.rs new file mode 100644 index 0000000..639278c --- /dev/null +++ b/common/rust/src/discord_models/invite.rs @@ -0,0 +1,48 @@ +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::{ + application::Application, + channel::Channel, + guild::{Guild, GuildMember}, + user::User, +}; + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum InviteTargetTypes { + Stream = 1, + EmbeddedApplication = 2, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct InviteStageInstance { + pub members: Vec, + pub participant_count: i64, + pub speaker_count: i64, + pub topic: String, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Invite { + pub code: String, + pub guild: Option, + pub channel: Channel, + pub inviter: Option, + pub target_type: Option, + pub target_user: Option, + pub target_application: Option, + pub approximate_presence_count: Option, + pub approximate_member_count: Option, + pub expires_at: Option, + pub stage_instance: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct InviteMetadata { + pub uses: i64, + pub max_uses: i64, + pub max_age: i64, + pub temporary: bool, + pub created_at: String, +} diff --git a/common/rust/src/discord_models/message_components.rs b/common/rust/src/discord_models/message_components.rs new file mode 100644 index 0000000..f71d7ed --- /dev/null +++ b/common/rust/src/discord_models/message_components.rs @@ -0,0 +1,75 @@ +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::emoji::Emoji; + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ComponentTypes { + ActionRow = 1, + Button = 2, + SelectMenu = 3, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +/// Global representation of a Component, more detailed are Button (if button) and Select Menu (if select menu) +/// Action Rows are just type: 1, content + components +pub struct Component { + #[serde(rename = "type")] + pub type_: ComponentTypes, + pub custom_id: Option, + pub disabled: Option, + pub style: Option, + pub label: Option, + pub emoji: Option, + pub url: Option, + pub options: Vec, + pub placeholder: Option, + pub min_values: Option, + pub max_values: Option, + pub components: Option>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Button { + #[serde(rename = "type")] + /// it should be `2` + pub type_: ComponentTypes, + pub style: ButtonStyles, + pub label: Option, + pub emoji: Option, + pub custom_id: Option, + pub url: Option, + pub disabled: Option, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ButtonStyles { + Primary = 1, + Secondary = 2, + Success = 3, + Danger = 4, + Link = 5, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct SelectOption { + pub label: String, + pub value: String, + pub description: Option, + pub emoji: Option, + pub default: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct SelectMenu { + /// it should be 3 + pub type_: ComponentTypes, + pub custom_id: String, + pub options: Vec, + pub placeholder: Option, + pub min_values: Option, + pub max_values: Option, + pub disabled: Option, +} diff --git a/common/rust/src/discord_models/mod.rs b/common/rust/src/discord_models/mod.rs index 29bf5a6..8017e2a 100644 --- a/common/rust/src/discord_models/mod.rs +++ b/common/rust/src/discord_models/mod.rs @@ -1,6 +1,16 @@ pub mod application; +pub mod audit_log; pub mod channel; +pub mod emoji; +pub mod gateway; pub mod guild; +pub mod guild_template; +pub mod invite; +pub mod message_components; +pub mod permissions; +pub mod slash_commands; pub mod stage_instance; pub mod teams; pub mod user; +pub mod voice; +pub mod webhook; diff --git a/common/rust/src/discord_models/permissions.rs b/common/rust/src/discord_models/permissions.rs new file mode 100644 index 0000000..76fa34a --- /dev/null +++ b/common/rust/src/discord_models/permissions.rs @@ -0,0 +1,21 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct RoleTags { + pub bot_id: Option, + pub integration_id: Option, + pub premium_subscriber: Option, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Role { + pub id: String, + pub name: String, + pub color: i64, + pub hoist: bool, + pub position: i64, + pub permissions: String, + pub managed: bool, + pub mentionable: bool, + pub tags: Option, +} diff --git a/common/rust/src/discord_models/slash_commands.rs b/common/rust/src/discord_models/slash_commands.rs new file mode 100644 index 0000000..919fb60 --- /dev/null +++ b/common/rust/src/discord_models/slash_commands.rs @@ -0,0 +1,87 @@ +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::user::User; + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ApplicationCommandOptionType { + SubCommand = 1, + SubCommandGroup = 2, + String = 3, + Integer = 4, + Boolean = 5, + User = 6, + Channel = 7, + Role = 8, + Mentionable = 8, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ApplicationCommandOptionChoice { + pub name: String, + /// todo: Can also be a String!!!! + pub value: i64, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ApplicationCommandOption { + #[serde(rename = "type")] + pub type_: ApplicationCommandOptionType, + pub name: String, + pub description: String, + pub required: Option, + pub choices: Option>, + pub options: Option>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ApplicationCommand { + pub id: String, + pub application_id: String, + pub guild_id: Option, + pub name: String, + pub description: String, + pub options: Option>, + pub default_permission: Option, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum ApplicationCommandPermissionType { + Role = 1, + User = 2, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GuildApplicationCommandPermissions { + pub id: String, + pub application_id: String, + pub guild_id: String, + pub permissions: Vec, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ApplicationCommandPermissions { + pub id: String, + #[serde(rename = "type")] + pub type_: ApplicationCommandPermissionType, + pub permission: bool, +} + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum InteractionRequestType { + Ping = 1, + ApplicationCommand = 2, + MessageComponent = 3, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MessageInteraction { + pub id: String, + #[serde(rename = "type")] + pub type_: InteractionRequestType, + pub name: String, + pub user: User, +} diff --git a/common/rust/src/discord_models/voice.rs b/common/rust/src/discord_models/voice.rs new file mode 100644 index 0000000..8263af5 --- /dev/null +++ b/common/rust/src/discord_models/voice.rs @@ -0,0 +1,30 @@ +use serde::{Deserialize, Serialize}; + +use super::guild::GuildMember; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct VoiceState { + pub guild_id: Option, + pub channel_id: Option, + pub user_id: String, + pub member: Option, + pub session_id: 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, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct VoiceRegion { + pub id: String, + pub name: String, + pub vip: bool, + pub optimal: bool, + pub deprecated: bool, + pub custom: bool, +} diff --git a/common/rust/src/discord_models/webhook.rs b/common/rust/src/discord_models/webhook.rs new file mode 100644 index 0000000..4648772 --- /dev/null +++ b/common/rust/src/discord_models/webhook.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +use super::{channel::Channel, guild::Guild, user::User}; + +#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] +#[repr(u8)] +pub enum WebhookTypes { + Incoming = 1, + ChannelFollower = 2, + Application = 3, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Webhook { + pub id: String, + #[serde(rename = "type")] + pub type_: WebhookTypes, + pub guild_id: Option, + pub channel_id: Option, + pub user: Option, + pub name: Option, + pub avatar: Option, + pub token: Option, + pub application_id: Option, + pub source_guild: Option, + pub source_channel: Option, + pub url: String, +}