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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::entities::UserApiType;
use super::{
ChannelTypeApiType, DefaultReactionApiType, ForumTagApiType, OverwritesApiType,
ThreadMemberApiType, ThreadMetadataApiType,
};
/// <https://discord.com/developers/docs/resources/channel#channel-object>
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ChannelApiType {
/// the id of this channel
pub id: String,
/// the type of channel
#[serde(rename = "type")]
pub type_: ChannelTypeApiType,
/// the id of the guild (may be missing for some channel objects received over gateway guild dispatches)
#[serde(skip_serializing_if = "Option::is_none")]
pub guild_id: Option<String>,
/// sorting position of the channel
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<u64>,
/// explicit permission overwrites for members and roles
#[serde(skip_serializing_if = "Option::is_none")]
pub permission_overwrites: Option<Vec<OverwritesApiType>>,
/// the name of the channel (1-100 characters)
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// the channel topic (0-1024 characters)
#[serde(skip_serializing_if = "Option::is_none")]
pub topic: Option<String>,
/// whether the channel is nsfw
#[serde(skip_serializing_if = "Option::is_none")]
pub nsfw: Option<bool>,
/// the id of the last message sent in this channel (or thread for GUILD_FORUM channels) (may not point to an existing or valid message or thread)
#[serde(skip_serializing_if = "Option::is_none")]
pub last_message_id: Option<String>,
/// the bitrate (in bits) of the voice channel
#[serde(skip_serializing_if = "Option::is_none")]
pub bitrate: Option<u64>,
/// the user limit of the voice channel
#[serde(skip_serializing_if = "Option::is_none")]
pub user_limit: Option<u64>,
/// amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected
#[serde(skip_serializing_if = "Option::is_none")]
pub rate_limit_per_user: Option<u64>,
/// the recipients of the DM
#[serde(skip_serializing_if = "Option::is_none")]
pub recipients: Option<Vec<UserApiType>>,
/// icon hash of the group DM
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<String>,
/// id of the creator of the group DM or thread
#[serde(skip_serializing_if = "Option::is_none")]
pub owner_id: Option<String>,
/// application id of the group DM creator if it is bot-created
#[serde(skip_serializing_if = "Option::is_none")]
pub application_id: Option<String>,
/// for guild channels: id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option<String>,
/// when the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned.
#[serde(skip_serializing_if = "Option::is_none")]
pub last_pin_timestamp: Option<String>,
/// voice region id for the voice channel, automatic when set to null
#[serde(skip_serializing_if = "Option::is_none")]
pub rtc_region: Option<String>,
/// the camera video quality mode of the voice channel, 1 when not present
#[serde(skip_serializing_if = "Option::is_none")]
pub video_quality_mode: Option<VideoQualityModeApiType>,
/// an approximate count of messages in a thread, stops counting at 50
#[serde(skip_serializing_if = "Option::is_none")]
pub message_count: Option<u64>,
/// an approximate count of users in a thread, stops counting at 50
#[serde(skip_serializing_if = "Option::is_none")]
pub member_count: Option<u64>,
/// thread-specific fields not needed by other channels
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_metadata: Option<ThreadMetadataApiType>,
/// thread member object for the current user, if they have joined the thread, only included on certain API endpoints
#[serde(skip_serializing_if = "Option::is_none")]
pub member: Option<ThreadMemberApiType>,
/// default duration that the clients (not the API) will use for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
#[serde(skip_serializing_if = "Option::is_none")]
pub default_auto_archive_duration: Option<u64>,
/// computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a slash command interaction
#[serde(skip_serializing_if = "Option::is_none")]
pub permissions: Option<String>,
// <https://discord.com/developers/docs/resources/channel#channel-object-channel-flags>
/// channel flags combined as a bitfield
#[serde(skip_serializing_if = "Option::is_none")]
pub flags: Option<u64>,
/// number of messages ever sent in a thread
#[serde(skip_serializing_if = "Option::is_none")]
pub total_message_sent: Option<u64>,
/// the set of tags that can be used in a GUILD_FORUM or a GUILD_MEDIA channel
#[serde(skip_serializing_if = "Option::is_none")]
pub available_tags: Option<Vec<ForumTagApiType>>,
/// the IDs of the set of tags that have been applied to a thread in a GUILD_FORUM or a GUILD_MEDIA channel
#[serde(skip_serializing_if = "Option::is_none")]
pub applied_tags: Option<Vec<String>>,
/// the emoji to show in the add reaction button on a thread in a GUILD_FORUM or a GUILD_MEDIA channel
#[serde(skip_serializing_if = "Option::is_none")]
pub default_reaction_emoji: Option<DefaultReactionApiType>,
/// the initial rate_limit_per_user to set on newly created threads in a channel
#[serde(skip_serializing_if = "Option::is_none")]
pub default_thread_rate_limit_per_user: Option<u64>,
/// the default sort order type used to order posts in GUILD_FORUM and GUILD_MEDIA channels
#[serde(skip_serializing_if = "Option::is_none")]
pub default_sort_order: Option<u8>,
/// the default forum layout view used to display posts in GUILD_FORUM channels
#[serde(skip_serializing_if = "Option::is_none")]
pub default_forum_layout: Option<u8>,
/// for group DM channels: whether the channel is managed by an application via the gdm.join OAuth2 scope
#[serde(skip_serializing_if = "Option::is_none")]
pub managed: Option<bool>,
}
/// <https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes>
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone)]
#[repr(u8)]
pub enum VideoQualityModeApiType {
#[default]
AUTO = 1,
FULL = 2,
}