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

Box big model type fields #2205

Merged
merged 4 commits into from
Oct 8, 2022
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
4 changes: 4 additions & 0 deletions examples/testing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use serenity::model::prelude::interaction::application_command::*;
use serenity::model::prelude::*;
use serenity::prelude::*;

mod model_type_sizes;

const IMAGE_URL: &str = "https://raw.githubusercontent.com/serenity-rs/serenity/current/logo.png";
const IMAGE_URL_2: &str = "https://rustacean.net/assets/rustlogo.png";

Expand Down Expand Up @@ -60,6 +62,8 @@ async fn message(ctx: &Context, msg: Message) -> Result<(), serenity::Error> {
.add_existing_attachment(msg.attachments[0].id),
)
.await?;
} else if msg.content == "ranking" {
model_type_sizes::print_ranking();
} else if msg.content == "auditlog" {
// Test special characters in audit log reason
msg.channel_id
Expand Down
293 changes: 293 additions & 0 deletions examples/testing/src/model_type_sizes.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/model/application/interaction/application_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct ApplicationCommandInteraction {
///
/// **Note**: It is only present if the interaction is triggered in a guild.
#[serde(skip_serializing_if = "Option::is_none")]
pub member: Option<Member>,
pub member: Option<Box<Member>>,
/// The `user` object for the invoking user.
pub user: User,
/// A continuation token for responding to the interaction.
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<'de> Deserialize<'de> for ApplicationCommandInteraction {
add_guild_id_to_resolved(&mut map, guild_id);
}

let member = remove_from_map_opt::<Member, _>(&mut map, "member")?;
let member = remove_from_map_opt::<Box<Member>, _>(&mut map, "member")?;
let user = remove_from_map_opt(&mut map, "user")?
.or_else(|| member.as_ref().map(|m| m.user.clone()))
.ok_or_else(|| DeError::custom("expected user or member"))?;
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/interaction/message_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct MessageComponentInteraction {
pub version: u8,
/// The message this interaction was triggered by, if
/// it is a component.
pub message: Message,
pub message: Box<Message>,
/// Permissions the app or bot has within the channel the interaction was sent from.
pub app_permissions: Option<Permissions>,
/// The selected language of the invoking user.
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/interaction/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct ModalSubmitInteraction {
/// **Note**: Does not exist if the modal interaction originates from
/// an application command interaction
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<Message>,
pub message: Option<Box<Message>>,
/// Permissions the app or bot has within the channel the interaction was sent from.
pub app_permissions: Option<Permissions>,
/// The selected language of the invoking user.
Expand Down
6 changes: 3 additions & 3 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct Message {
pub kind: MessageType,
/// A partial amount of data about the user's member data, if this message
/// was sent in a guild.
pub member: Option<PartialMember>,
pub member: Option<Box<PartialMember>>,
/// Indicator of whether the message mentions everyone.
pub mention_everyone: bool,
/// Array of [`Role`]s' Ids mentioned in the message.
Expand Down Expand Up @@ -120,7 +120,7 @@ pub struct Message {
/// Sent if the message is a response to an [`Interaction`].
///
/// [`Interaction`]: crate::model::application::interaction::Interaction
pub interaction: Option<MessageInteraction>,
pub interaction: Option<Box<MessageInteraction>>,
/// The components of this message
#[serde(default)]
pub components: Vec<ActionRow>,
Expand Down Expand Up @@ -539,7 +539,7 @@ impl Message {
message_id: self.id,
user_id,
guild_id: self.guild_id,
member: self.member.clone(),
member: self.member.as_deref().cloned(),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/custom_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl CustomMessage {
/// [author]: Self::author
#[inline]
pub fn member(&mut self, member: PartialMember) -> &mut Self {
self.msg.member = Some(member);
self.msg.member = Some(Box::new(member));

self
}
Expand Down