]> git.puffer.fish Git - matthieu/nova.git/commitdiff
Add structures
authorn1c00o <git.n1c00o@gmail.com>
Mon, 4 Oct 2021 18:24:16 +0000 (20:24 +0200)
committern1c00o <git.n1c00o@gmail.com>
Mon, 4 Oct 2021 18:24:16 +0000 (20:24 +0200)
13 files changed:
common/rust/src/discord_models/audit_log.rs [new file with mode: 0644]
common/rust/src/discord_models/channel.rs
common/rust/src/discord_models/emoji.rs [new file with mode: 0644]
common/rust/src/discord_models/gateway.rs [new file with mode: 0644]
common/rust/src/discord_models/guild.rs
common/rust/src/discord_models/guild_template.rs [new file with mode: 0644]
common/rust/src/discord_models/invite.rs [new file with mode: 0644]
common/rust/src/discord_models/message_components.rs [new file with mode: 0644]
common/rust/src/discord_models/mod.rs
common/rust/src/discord_models/permissions.rs [new file with mode: 0644]
common/rust/src/discord_models/slash_commands.rs [new file with mode: 0644]
common/rust/src/discord_models/voice.rs [new file with mode: 0644]
common/rust/src/discord_models/webhook.rs [new file with mode: 0644]

diff --git a/common/rust/src/discord_models/audit_log.rs b/common/rust/src/discord_models/audit_log.rs
new file mode 100644 (file)
index 0000000..ad63277
--- /dev/null
@@ -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<String>,
+    pub members_removed: Option<String>,
+    pub channel_id: Option<String>,
+    pub message_id: Option<String>,
+    pub count: Option<String>,
+    pub id: Option<String>,
+    #[serde(rename = "type")]
+    pub type_: Option<OptionalAuditEntryInfo>,
+    pub role_name: Option<String>,
+}
+
+#[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<String>,
+    pub old_value: Option<String>,
+    pub key: AuditLogChangeKey,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct AuditLogEntry {
+    pub target_id: Option<String>,
+    pub changes: Option<Vec<AuditLogChange>>,
+    pub user_id: Option<String>,
+    pub id: String,
+    pub action_type: AuditLogEvents,
+    pub options: Option<OptionalAuditEntryInfo>,
+    pub reason: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct AuditLog {
+    pub webhooks: Vec<Webhook>,
+    pub users: Vec<User>,
+    pub audit_log_entries: Vec<AuditLogEntry>,
+    pub integrations: Vec<Integration>,
+}
index 41f4a4be72e2c0dacc11a6f27b0b2ec9eef92e9d..980960b7a025479ca2b4500fc1b8d437297424fb 100644 (file)
@@ -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<ThreadMember>,
     pub default_auto_archive_duration: Option<i64>,
 }
+
+#[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<i64>,
+    pub width: Option<i64>,
+}
+
+#[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<String>,
+    pub proxy_url: Option<String>,
+    pub height: Option<i64>,
+    pub width: Option<i64>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedVideo {
+    pub url: Option<String>,
+    pub proxy_url: Option<String>,
+    pub height: Option<i64>,
+    pub width: Option<i64>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedImage {
+    pub url: Option<String>,
+    pub proxy_url: Option<String>,
+    pub height: Option<i64>,
+    pub width: Option<i64>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedProvider {
+    pub name: Option<String>,
+    pub url: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedAuthor {
+    pub name: Option<String>,
+    pub url: Option<String>,
+    pub icon_url: Option<String>,
+    pub proxy_icon_url: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedFooter {
+    pub text: String,
+    pub icon_url: Option<String>,
+    pub proxy_icon_url: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct EmbedField {
+    pub name: String,
+    pub value: String,
+    pub inline: Option<bool>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Embed {
+    pub title: Option<String>,
+    #[serde(rename = "type")]
+    pub type_: Option<EmbedTypes>,
+    pub description: Option<String>,
+    pub url: Option<String>,
+    pub timestamp: Option<String>,
+    pub color: Option<i64>,
+    pub footer: Option<EmbedFooter>,
+    pub image: Option<EmbedImage>,
+    pub thumbnail: Option<EmbedThumbnail>,
+    pub video: Option<EmbedVideo>,
+    pub provider: Option<EmbedProvider>,
+    pub author: Option<EmbedAuthor>,
+    pub fields: Option<Vec<EmbedField>>,
+}
+
+#[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<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct MessageReference {
+    pub message_id: Option<String>,
+    pub channel_id: Option<String>,
+    pub guild_id: Option<String>,
+    pub fail_if_not_exists: Option<bool>,
+}
+
+#[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<String>,
+    pub name: String,
+    pub description: String,
+    pub tags: String,
+    // deprecated
+    // pub asset: String,
+    pub format_type: MessageStickerFormatTypes,
+    pub available: Option<bool>,
+    pub guild_id: Option<String>,
+    pub user: Option<User>,
+    pub sort_value: Option<i64>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Message {
+    pub id: String,
+    pub channel_id: String,
+    pub guild_id: Option<String>,
+    pub author: User,
+    pub member: Option<GuildMember>,
+    pub content: String,
+    pub timestamp: String,
+    pub edited_timestamp: String,
+    pub tts: bool,
+    pub mention_everyone: bool,
+    pub mentions: Vec<User>, // todo: It is a Vector of User objects, with an additional partial member field (GuildMember)
+    pub mentions_roles: Vec<String>,
+    pub mention_channels: Option<Vec<Channel>>,
+    pub attachments: Vec<Attachment>,
+    pub embeds: Vec<Embed>,
+    pub reactions: Option<Vec<Reaction>>,
+    /// ! Can be a String or an int !
+    pub nonce: Option<String>,
+    pub pinned: bool,
+    pub webhook_id: Option<String>,
+    #[serde(rename = "type")]
+    pub type_: MessageTypes,
+    pub activity: Option<MessageActivity>,
+    pub application: Option<Application>,
+    pub application_id: Option<String>,
+    pub message_reference: Option<MessageReference>,
+    pub flags: Option<BitFlags<MessageFlags>>,
+    pub referenced_message: Option<Message>,
+    pub interaction: Option<MessageInteraction>,
+    pub thread: Option<Channel>,
+    pub components: Option<Component>,
+    pub sticker_items: Option<Vec<MessageStickerItem>>,
+    // deprecated
+    // pub stickers: Option<Vec<MessageSticker>>,
+}
diff --git a/common/rust/src/discord_models/emoji.rs b/common/rust/src/discord_models/emoji.rs
new file mode 100644 (file)
index 0000000..eec02e7
--- /dev/null
@@ -0,0 +1,15 @@
+use serde::{Deserialize, Serialize};
+
+use super::user::User;
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Emoji {
+    pub id: Option<String>,
+    pub name: Option<String>,
+    pub roles: Vec<String>,
+    pub user: Option<User>,
+    pub require_colons: Option<bool>,
+    pub managed: Option<bool>,
+    pub animated: Option<bool>,
+    pub available: Option<bool>,
+}
diff --git a/common/rust/src/discord_models/gateway.rs b/common/rust/src/discord_models/gateway.rs
new file mode 100644 (file)
index 0000000..dbdf60d
--- /dev/null
@@ -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<String>,
+    pub mobile: Option<String>,
+    pub web: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct PresenceUpdate {
+    pub user: User,
+    pub guild_id: String,
+    pub status: PresenceUpdateStatus,
+    pub activities: Vec<Activity>,
+    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<i64>,
+    pub end: Option<i64>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ActivityEmoji {
+    pub name: String,
+    pub id: Option<String>,
+    pub animated: Option<bool>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ActivityParty {
+    pub id: Option<String>,
+    /// [current_size, max_size]
+    pub size: Option<Vec<i64>>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ActivityAssets {
+    pub large_image: Option<String>,
+    pub large_text: Option<String>,
+    pub small_image: Option<String>,
+    pub small_text: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ActivitySecrets {
+    pub join: Option<String>,
+    pub spectate: Option<String>,
+    #[serde(rename = "match")]
+    pub match_: Option<String>,
+}
+
+#[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<String>,
+    pub created_at: String,
+    pub timestamps: Option<ActivityTimestamps>,
+    pub application_id: Option<String>,
+    pub details: Option<String>,
+    pub state: Option<String>,
+    pub emoji: Option<ActivityEmoji>,
+    pub party: Option<ActivityParty>,
+    pub assets: Option<ActivityAssets>,
+    pub secrets: Option<ActivitySecrets>,
+    pub instance: Option<bool>,
+    pub flags: Option<BitFlags<ActivityFlags>>,
+    pub buttons: Option<Vec<ActivityButtons>>,
+}
index 92a11e74fdc4d7bef2a18d8d9ff111858e548eeb..85da5b2261017343b26bf70b5cd540e0d81e3619 100644 (file)
@@ -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<bool>,
     pub application: Option<IntegrationApplication>,
 }
+
+#[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<String>,
+    pub emoji_name: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct WelcomeScreen {
+    pub description: String,
+    pub welcome_channels: Vec<WelcomeScreenChannel>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Guild {
+    pub id: String,
+    pub name: String,
+    pub icon: Option<String>,
+    pub icon_hash: Option<String>,
+    pub splash: Option<String>,
+    pub discovery_splash: Option<String>,
+    pub owner: Option<bool>,
+    pub owner_id: String,
+    pub permissions: Option<String>,
+    /// DEPRECATED
+    pub region: Option<String>,
+    pub afk_channel_id: Option<String>,
+    pub afk_timeout: i64,
+    pub widget_enabled: Option<bool>,
+    pub widget_channel_id: Option<String>,
+    pub verification_level: VerificationLevel,
+    pub default_message_notifications: DefaultMessageNotificationLevel,
+    pub explicit_content_filter: ExplicitContentFilter,
+    pub roles: Vec<Role>,
+    pub emojis: Vec<Emoji>,
+    pub features: Vec<GuildFeatures>,
+    pub mfa_level: MfaLevel,
+    pub application_id: Option<String>,
+    pub system_channel_id: Option<String>,
+    pub system_channel_flags: BitFlags<SystemChannelFlags>,
+    pub rules_channel_id: Option<String>,
+    pub joined_at: Option<String>,
+    pub large: Option<bool>,
+    pub unavailable: Option<bool>,
+    pub member_count: Option<i64>,
+    pub voice_states: Option<Vec<VoiceState>>,
+    pub members: Option<Vec<GuildMember>>,
+    pub channels: Option<Vec<Channel>>,
+    pub threads: Option<Vec<Channel>>,
+    pub presences: Option<Vec<PresenceUpdate>>,
+    pub max_presences: Option<i64>,
+    pub vanity_url_code: Option<String>,
+    pub description: Option<String>,
+    pub banner: Option<String>,
+    pub premium_tier: PremiumTier,
+    pub premium_subscription_count: i64,
+    pub preferred_locale: String,
+    pub public_updates_channel_id: Option<String>,
+    pub max_video_channel_users: Option<i64>,
+    pub approximate_member_count: Option<i64>,
+    pub welcome_screen: Option<WelcomeScreen>,
+    pub nsfw_level: GuildNsfwLevel,
+    pub stage_instances: Option<Vec<StageInstance>>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct GuildMember {
+    pub user: Option<User>,
+    pub nick: Option<String>,
+    pub roles: Vec<String>,
+    pub joined_at: String,
+    pub premium_since: Option<String>,
+    pub deaf: bool,
+    pub mute: bool,
+    pub pending: Option<bool>,
+    pub permissions: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct GuildPreview {
+    pub id: String,
+    pub name: String,
+    pub icon: Option<String>,
+    pub splash: Option<String>,
+    pub discovery_splash: Option<String>,
+    pub emojis: Vec<Emoji>,
+    pub features: Vec<GuildFeatures>,
+    pub approximate_member_count: i64,
+    pub approximate_presence_count: i64,
+    pub description: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct GuildWidget {
+    pub enabled: bool,
+    pub channel_id: Option<String>,
+}
diff --git a/common/rust/src/discord_models/guild_template.rs b/common/rust/src/discord_models/guild_template.rs
new file mode 100644 (file)
index 0000000..960631d
--- /dev/null
@@ -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<String>,
+    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<bool>,
+}
diff --git a/common/rust/src/discord_models/invite.rs b/common/rust/src/discord_models/invite.rs
new file mode 100644 (file)
index 0000000..639278c
--- /dev/null
@@ -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<GuildMember>,
+    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<Guild>,
+    pub channel: Channel,
+    pub inviter: Option<User>,
+    pub target_type: Option<InviteTargetTypes>,
+    pub target_user: Option<User>,
+    pub target_application: Option<Application>,
+    pub approximate_presence_count: Option<i64>,
+    pub approximate_member_count: Option<i64>,
+    pub expires_at: Option<String>,
+    pub stage_instance: Option<InviteStageInstance>,
+}
+
+#[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 (file)
index 0000000..f71d7ed
--- /dev/null
@@ -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<String>,
+    pub disabled: Option<bool>,
+    pub style: Option<ButtonStyles>,
+    pub label: Option<String>,
+    pub emoji: Option<Emoji>,
+    pub url: Option<String>,
+    pub options: Vec<SelectOption>,
+    pub placeholder: Option<String>,
+    pub min_values: Option<u8>,
+    pub max_values: Option<u8>,
+    pub components: Option<Vec<Component>>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct Button {
+    #[serde(rename = "type")]
+    /// it should be `2`
+    pub type_: ComponentTypes,
+    pub style: ButtonStyles,
+    pub label: Option<String>,
+    pub emoji: Option<Emoji>,
+    pub custom_id: Option<String>,
+    pub url: Option<String>,
+    pub disabled: Option<bool>,
+}
+
+#[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<String>,
+    pub emoji: Option<Emoji>,
+    pub default: Option<bool>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct SelectMenu {
+    /// it should be 3
+    pub type_: ComponentTypes,
+    pub custom_id: String,
+    pub options: Vec<SelectOption>,
+    pub placeholder: Option<String>,
+    pub min_values: Option<u8>,
+    pub max_values: Option<u8>,
+    pub disabled: Option<bool>,
+}
index 29bf5a6ccbd871132009ae583f4b56b1324c6438..8017e2a585af5538ded865175944567baef1626a 100644 (file)
@@ -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 (file)
index 0000000..76fa34a
--- /dev/null
@@ -0,0 +1,21 @@
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct RoleTags {
+  pub bot_id: Option<String>,
+  pub integration_id: Option<String>,
+  pub premium_subscriber: Option<bool>,
+}
+
+#[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<RoleTags>,
+}
diff --git a/common/rust/src/discord_models/slash_commands.rs b/common/rust/src/discord_models/slash_commands.rs
new file mode 100644 (file)
index 0000000..919fb60
--- /dev/null
@@ -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<bool>,
+    pub choices: Option<Vec<ApplicationCommandOptionChoice>>,
+    pub options: Option<Vec<ApplicationCommandOption>>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ApplicationCommand {
+    pub id: String,
+    pub application_id: String,
+    pub guild_id: Option<String>,
+    pub name: String,
+    pub description: String,
+    pub options: Option<Vec<ApplicationCommandOption>>,
+    pub default_permission: Option<bool>,
+}
+
+#[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<ApplicationCommandPermissions>,
+}
+
+#[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 (file)
index 0000000..8263af5
--- /dev/null
@@ -0,0 +1,30 @@
+use serde::{Deserialize, Serialize};
+
+use super::guild::GuildMember;
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct VoiceState {
+    pub guild_id: Option<String>,
+    pub channel_id: Option<String>,
+    pub user_id: String,
+    pub member: Option<GuildMember>,
+    pub session_id: String,
+    pub deaf: bool,
+    pub mute: bool,
+    pub self_deaf: bool,
+    pub self_mute: bool,
+    pub self_stream: Option<bool>,
+    pub self_video: bool,
+    pub suppress: bool,
+    pub request_to_speak_timestamp: Option<String>,
+}
+
+#[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 (file)
index 0000000..4648772
--- /dev/null
@@ -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<String>,
+    pub channel_id: Option<String>,
+    pub user: Option<User>,
+    pub name: Option<String>,
+    pub avatar: Option<String>,
+    pub token: Option<String>,
+    pub application_id: Option<String>,
+    pub source_guild: Option<Guild>,
+    pub source_channel: Option<Channel>,
+    pub url: String,
+}