composure/types/invite.rs
1use serde::Deserialize;
2use serde_repr::{Deserialize_repr, Serialize_repr};
3
4use crate::types::{PartialChannel, PartialGuild, Snowflake, User};
5
6/// [Invite](https://discord.com/developers/docs/resources/invite#invite-object), with
7/// [metadata](https://discord.com/developers/docs/resources/invite#invite-metadata-object) when
8/// listed from a channel or guild
9#[derive(Debug, Clone, Deserialize)]
10pub struct Invite {
11 /// 0 guild, 1 group DM, 2 friend
12 #[serde(rename = "type", default)]
13 pub kind: u8,
14
15 /// The `discord.gg/<code>` code
16 pub code: String,
17
18 /// The guild it invites to
19 pub guild: Option<PartialGuild>,
20
21 /// The channel it invites to
22 pub channel: Option<PartialChannel>,
23
24 /// Who created it
25 pub inviter: Option<User>,
26
27 /// What a voice channel invite targets
28 pub target_type: Option<InviteTargetType>,
29
30 /// Whose stream it shows, for stream invites
31 pub target_user: Option<User>,
32
33 /// With `with_counts`
34 pub approximate_member_count: Option<u32>,
35
36 /// With `with_counts`
37 pub approximate_presence_count: Option<u32>,
38
39 /// ISO 8601; `None` for invites that never expire
40 pub expires_at: Option<String>,
41
42 /// Metadata: times used
43 pub uses: Option<u32>,
44
45 /// Metadata: use limit, 0 for unlimited
46 pub max_uses: Option<u32>,
47
48 /// Metadata: lifetime in seconds, 0 for forever
49 pub max_age: Option<u32>,
50
51 /// Metadata: membership is temporary
52 pub temporary: Option<bool>,
53
54 /// Metadata: ISO 8601
55 pub created_at: Option<String>,
56}
57
58/// [Invite Target Type](https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types)
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize_repr, Serialize_repr)]
60#[repr(u8)]
61pub enum InviteTargetType {
62 /// A user's stream in a voice channel
63 Stream = 1,
64 /// An embedded application (an Activity) in a voice channel
65 EmbeddedApplication = 2,
66}
67
68/// [Ban](https://discord.com/developers/docs/resources/guild#ban-object)
69#[derive(Debug, Clone, Deserialize)]
70pub struct Ban {
71 /// Why they were banned
72 pub reason: Option<String>,
73 /// The banned user
74 pub user: User,
75}
76
77/// Result of a [bulk ban](https://discord.com/developers/docs/resources/guild#bulk-guild-ban)
78#[derive(Debug, Clone, Deserialize)]
79pub struct BulkBan {
80 /// Users who were banned
81 pub banned_users: Vec<Snowflake>,
82 /// Users who could not be banned (missing permissions, already banned, ...)
83 pub failed_users: Vec<Snowflake>,
84}