Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model, cache): add managed field to Channel #2148

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions twilight-cache-inmemory/src/event/guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ mod tests {
kind: ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -360,6 +361,7 @@ mod tests {
kind: ChannelType::PublicThread,
last_message_id: None,
last_pin_timestamp: None,
managed: Some(true),
member: Some(ThreadMember {
flags: 0,
id: Some(Id::new(1)),
Expand Down
2 changes: 2 additions & 0 deletions twilight-cache-inmemory/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ mod tests {
kind: ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -838,6 +839,7 @@ mod tests {
kind: ChannelType::PublicThread,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ pub fn guild_channel_text() -> (Id<GuildMarker>, Id<ChannelMarker>, Channel) {
kind: ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down
18 changes: 18 additions & 0 deletions twilight-model/src/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ pub struct Channel {
/// ID of the last message pinned in the channel.
#[serde(skip_serializing_if = "Option::is_none")]
pub last_pin_timestamp: Option<Timestamp>,
/// Whether the channel is managed by an application via the [`gdm.join`]
/// oauth scope.
///
/// This is only applicable to [group channels].
///
/// [`gdm.join`]: https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
/// [group channels]: ChannelType::Group
#[serde(skip_serializing_if = "Option::is_none")]
pub managed: Option<bool>,
/// Member that created the channel.
#[serde(skip_serializing_if = "Option::is_none")]
pub member: Option<ThreadMember>,
Expand Down Expand Up @@ -236,6 +245,7 @@ mod tests {
kind: ChannelType::GuildText,
last_message_id: Some(Id::new(3)),
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -278,6 +288,7 @@ mod tests {
kind: ChannelType::GuildCategory,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -332,6 +343,7 @@ mod tests {
kind: ChannelType::GuildAnnouncement,
last_message_id: Some(Id::new(4)),
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -393,6 +405,7 @@ mod tests {
kind: ChannelType::AnnouncementThread,
last_message_id: Some(Id::new(3)),
last_pin_timestamp: None,
managed: Some(true),
member: Some(ThreadMember {
flags: 0_u64,
id: Some(Id::new(4)),
Expand Down Expand Up @@ -440,6 +453,7 @@ mod tests {
"user_id": "5",
},
"default_auto_archive_duration": 60,
"managed": true,
"member_count": 50,
"message_count": 50,
"name": "newsthread",
Expand Down Expand Up @@ -481,6 +495,7 @@ mod tests {
kind: ChannelType::PublicThread,
last_message_id: Some(Id::new(3)),
last_pin_timestamp: None,
managed: Some(true),
member: Some(ThreadMember {
flags: 0_u64,
id: Some(Id::new(4)),
Expand Down Expand Up @@ -528,6 +543,7 @@ mod tests {
"user_id": "5",
},
"default_auto_archive_duration": 60,
"managed": true,
"member_count": 50,
"message_count": 50,
"name": "publicthread",
Expand Down Expand Up @@ -570,6 +586,7 @@ mod tests {
kind: ChannelType::PrivateThread,
last_message_id: Some(Id::new(3)),
last_pin_timestamp: None,
managed: Some(true),
member: Some(ThreadMember {
flags: 0_u64,
id: Some(Id::new(4)),
Expand Down Expand Up @@ -625,6 +642,7 @@ mod tests {
},
"default_auto_archive_duration": 60,
"invitable": true,
"managed": true,
"member_count": -1,
"message_count": 50,
"name": "privatethread",
Expand Down
4 changes: 4 additions & 0 deletions twilight-model/src/guild/template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ mod tests {
kind: ChannelType::GuildCategory,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -257,6 +258,7 @@ mod tests {
kind: ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -306,6 +308,7 @@ mod tests {
kind: ChannelType::GuildCategory,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down Expand Up @@ -342,6 +345,7 @@ mod tests {
kind: ChannelType::GuildVoice,
last_message_id: None,
last_pin_timestamp: None,
managed: None,
member: None,
member_count: None,
message_count: None,
Expand Down