1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Structures related to a Discord invite.
use chrono::{DateTime, FixedOffset};

use crate::channel::Channel;
use crate::guild::Guild;
use crate::User;

/// Represents a code that when used, adds a user to a guild or group DM channel.
#[derive(Deserialize, Serialize, Clone, Debug, Default)]
pub struct Invite {
    /// The ID of the invite code.
    pub code: String,
    /// The guild that the invite belongs to.
    #[serde(default)]
    pub guild: Guild,
    /// The channel that the invite belongs to.
    pub channel: Channel,
    /// The approximate count of online members.
    #[serde(default)]
    pub approximate_presence_count: i32,
    /// The approximate count of total members.
    #[serde(default)]
    pub approximate_member_count: i32
}

/// Detailed information about an invite.
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct InviteMetadata {
    /// The user who created the invite.
    pub inviter: User,
    /// The amount of times that this invite has been used.
    pub uses: i32,
    /// The maximum amount of uses allowed for this invite.
    pub max_uses: i32,
    /// The duration after which the invite expires, in seconds.
    pub max_age: i32,
    /// Whether or not this invite grants temporary membership.
    pub temporary: bool,
    /// The date that this invite was created.
    pub created_at: DateTime<FixedOffset>,
    /// Whether or not this invite has been revoked.
    pub revoked: bool
}