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): add avatar decoration data #2343

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions twilight-cache-inmemory/src/event/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar3),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -250,6 +251,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar2),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 5678,
Expand Down Expand Up @@ -289,6 +291,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar3),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1234,
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/event/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/event/voice_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/model/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ mod tests {
accent_color: None,
avatar: None,
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/model/sticker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ mod tests {
accent_color: None,
avatar: Some(avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down
4 changes: 4 additions & 0 deletions twilight-cache-inmemory/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache {
accent_color: None,
avatar: Some(avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -122,6 +123,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache {
accent_color: None,
avatar: Some(avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -163,6 +165,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache {
accent_color: None,
avatar: Some(user_5_avatar),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 2,
Expand Down Expand Up @@ -358,6 +361,7 @@ pub fn user(id: Id<UserMarker>) -> User {
accent_color: None,
avatar: None,
avatar_decoration: None,
avatar_decoration_data: None,
banner: Some(banner),
bot: false,
discriminator: 1,
Expand Down
10 changes: 8 additions & 2 deletions twilight-model/src/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1111,
Expand Down Expand Up @@ -554,6 +555,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1111,
Expand Down Expand Up @@ -672,7 +674,7 @@ mod tests {
Token::Str("600"),
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -681,6 +683,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down Expand Up @@ -744,7 +748,7 @@ mod tests {
Token::Some,
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -753,6 +757,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down
10 changes: 8 additions & 2 deletions twilight-model/src/application/interaction/resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -263,6 +264,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -382,7 +384,7 @@ mod tests {
Token::Str("author"),
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -391,6 +393,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down Expand Up @@ -520,7 +524,7 @@ mod tests {
Token::Str("300"),
Token::Struct {
name: "User",
len: 16,
len: 17,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -529,6 +533,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down
5 changes: 4 additions & 1 deletion twilight-model/src/channel/message/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: Some(image_hash::BANNER),
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -128,7 +129,7 @@ mod tests {
Token::Str("user"),
Token::Struct {
name: "User",
len: 16,
len: 17,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -137,6 +138,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::Some,
Token::Str(image_hash::BANNER_INPUT),
Expand Down
10 changes: 8 additions & 2 deletions twilight-model/src/channel/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -299,7 +300,7 @@ mod tests {
Token::Str("author"),
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -308,6 +309,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down Expand Up @@ -431,6 +434,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -557,7 +561,7 @@ mod tests {
Token::Str("author"),
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -566,6 +570,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down
5 changes: 4 additions & 1 deletion twilight-model/src/channel/message/sticker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ mod tests {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -212,7 +213,7 @@ mod tests {
Token::Some,
Token::Struct {
name: "User",
len: 17,
len: 18,
},
Token::Str("accent_color"),
Token::None,
Expand All @@ -221,6 +222,8 @@ mod tests {
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down
5 changes: 4 additions & 1 deletion twilight-model/src/channel/webhook/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ mod tests {
accent_color: None,
avatar: None,
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1,
Expand Down Expand Up @@ -241,14 +242,16 @@ mod tests {
Token::Some,
Token::Struct {
name: "User",
len: 9,
len: 10,
},
Token::Str("accent_color"),
Token::None,
Token::Str("avatar"),
Token::None,
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Expand Down
18 changes: 9 additions & 9 deletions twilight-model/src/gateway/event/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use serde::{
#[serde(untagged)]
pub enum DispatchEvent {
AutoModerationActionExecution(AutoModerationActionExecution),
AutoModerationRuleCreate(Box<AutoModerationRuleCreate>),
AutoModerationRuleDelete(Box<AutoModerationRuleDelete>),
AutoModerationRuleUpdate(Box<AutoModerationRuleUpdate>),
AutoModerationRuleCreate(AutoModerationRuleCreate),
AutoModerationRuleDelete(AutoModerationRuleDelete),
AutoModerationRuleUpdate(AutoModerationRuleUpdate),
suneettipirneni marked this conversation as resolved.
Show resolved Hide resolved
BanAdd(BanAdd),
BanRemove(BanRemove),
ChannelCreate(Box<ChannelCreate>),
Expand Down Expand Up @@ -242,15 +242,15 @@ impl<'de, 'a> DeserializeSeed<'de> for DispatchEventWithTypeDeserializer<'a> {
"AUTO_MODERATION_ACTION_EXECUTION" => DispatchEvent::AutoModerationActionExecution(
AutoModerationActionExecution::deserialize(deserializer)?,
),
"AUTO_MODERATION_RULE_CREATE" => DispatchEvent::AutoModerationRuleCreate(Box::new(
"AUTO_MODERATION_RULE_CREATE" => DispatchEvent::AutoModerationRuleCreate(
AutoModerationRuleCreate::deserialize(deserializer)?,
)),
"AUTO_MODERATION_RULE_DELETE" => DispatchEvent::AutoModerationRuleDelete(Box::new(
),
"AUTO_MODERATION_RULE_DELETE" => DispatchEvent::AutoModerationRuleDelete(
AutoModerationRuleDelete::deserialize(deserializer)?,
)),
"AUTO_MODERATION_RULE_UPDATE" => DispatchEvent::AutoModerationRuleUpdate(Box::new(
),
"AUTO_MODERATION_RULE_UPDATE" => DispatchEvent::AutoModerationRuleUpdate(
AutoModerationRuleUpdate::deserialize(deserializer)?,
)),
),
"CHANNEL_CREATE" => {
DispatchEvent::ChannelCreate(Box::new(ChannelCreate::deserialize(deserializer)?))
}
Expand Down
14 changes: 7 additions & 7 deletions twilight-model/src/gateway/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub enum Event {
/// Message was blocked by AutoMod according to a rule.
AutoModerationActionExecution(AutoModerationActionExecution),
/// Sent when an auto moderation rule is created.
AutoModerationRuleCreate(Box<AutoModerationRuleCreate>),
AutoModerationRuleCreate(AutoModerationRuleCreate),
/// Sent when an auto moderation rule is deleted.
AutoModerationRuleDelete(Box<AutoModerationRuleDelete>),
AutoModerationRuleDelete(AutoModerationRuleDelete),
/// Sent when an auto moderation rule is updated.
AutoModerationRuleUpdate(Box<AutoModerationRuleUpdate>),
AutoModerationRuleUpdate(AutoModerationRuleUpdate),
/// A user was banned from a guild.
BanAdd(BanAdd),
/// A user's ban from a guild was removed.
Expand Down Expand Up @@ -457,14 +457,11 @@ mod tests {
// requires a variable to be used in a function, so this is a false
// positive.
#[allow(dead_code)]
const EVENT_THRESHOLD: usize = 224;
const EVENT_THRESHOLD: usize = 256;
laralove143 marked this conversation as resolved.
Show resolved Hide resolved

const_assert!(mem::size_of::<Event>() == EVENT_THRESHOLD);

// Boxed events.
const_assert!(mem::size_of::<AutoModerationRuleCreate>() > EVENT_THRESHOLD);
const_assert!(mem::size_of::<AutoModerationRuleDelete>() > EVENT_THRESHOLD);
const_assert!(mem::size_of::<AutoModerationRuleUpdate>() > EVENT_THRESHOLD);
const_assert!(mem::size_of::<ChannelCreate>() > EVENT_THRESHOLD);
const_assert!(mem::size_of::<ChannelDelete>() > EVENT_THRESHOLD);
const_assert!(mem::size_of::<ChannelUpdate>() > EVENT_THRESHOLD);
Expand All @@ -491,6 +488,9 @@ mod tests {
const_assert!(mem::size_of::<VoiceStateUpdate>() > EVENT_THRESHOLD);

// Unboxed.
const_assert!(mem::size_of::<AutoModerationRuleCreate>() <= EVENT_THRESHOLD);
const_assert!(mem::size_of::<AutoModerationRuleDelete>() <= EVENT_THRESHOLD);
const_assert!(mem::size_of::<AutoModerationRuleUpdate>() <= EVENT_THRESHOLD);
const_assert!(mem::size_of::<AutoModerationActionExecution>() <= EVENT_THRESHOLD);
const_assert!(mem::size_of::<BanAdd>() <= EVENT_THRESHOLD);
const_assert!(mem::size_of::<BanRemove>() <= EVENT_THRESHOLD);
Expand Down
Loading