Skip to content

Commit

Permalink
Remove recently deprecated items
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed May 14, 2024
1 parent 0dce623 commit c74e396
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 105 deletions.
1 change: 0 additions & 1 deletion examples/testing/src/model_type_sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ pub fn print_ranking() {
("MessageFlags", std::mem::size_of::<MessageFlags>()),
("MessageFlags", std::mem::size_of::<MessageFlags>()),
("MessageId", std::mem::size_of::<MessageId>()),
("MessageInteraction", std::mem::size_of::<MessageInteraction>()),
("MessageReaction", std::mem::size_of::<MessageReaction>()),
("MessageReference", std::mem::size_of::<MessageReference>()),
("MessageUpdateEvent", std::mem::size_of::<MessageUpdateEvent>()),
Expand Down
10 changes: 0 additions & 10 deletions src/builder/create_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ pub struct CreateCommand<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
default_member_permissions: Option<Permissions>,
#[serde(skip_serializing_if = "Option::is_none")]
dm_permission: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "type")]
kind: Option<CommandType>,
#[cfg(feature = "unstable")]
Expand All @@ -362,7 +360,6 @@ impl<'a> CreateCommand<'a> {
description: None,
description_localizations: HashMap::new(),
default_member_permissions: None,
dm_permission: None,

#[cfg(feature = "unstable")]
integration_types: None,
Expand Down Expand Up @@ -415,13 +412,6 @@ impl<'a> CreateCommand<'a> {
self
}

/// Specifies if the command is available in DMs.
#[cfg_attr(feature = "unstable", deprecated = "Use contexts instead")]
pub fn dm_permission(mut self, enabled: bool) -> Self {
self.dm_permission = Some(enabled);
self
}

/// Specifies the description of the application command.
///
/// **Note**: Must be between 1 and 100 characters long.
Expand Down
4 changes: 0 additions & 4 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ fn update_cache_with_event(
event,
}
},
#[allow(deprecated)]
Event::PresencesReplace(event) => FullEvent::PresenceReplace {
presences: event.presences.into_vec(),
},
Event::PresenceUpdate(mut event) => {
let old_data = if_cache!(event.update(cache));

Expand Down
3 changes: 0 additions & 3 deletions src/client/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ event_handler! {
/// Provides the channel's id and the message's id.
ReactionRemoveEmoji { removed_reactions: Reaction } => async fn reaction_remove_emoji(&self, ctx: Context);

#[deprecated = "This event does not exist"]
PresenceReplace { presences: Vec<Presence> } => async fn presence_replace(&self, ctx: Context);

/// Dispatched when a user's presence is updated (e.g off -> on).
///
/// Provides the presence's new data, as well as the old presence data if the
Expand Down
5 changes: 0 additions & 5 deletions src/model/application/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ pub struct Command {
pub options: FixedArray<CommandOption>,
/// The default permissions required to execute the command.
pub default_member_permissions: Option<Permissions>,
/// Indicates whether the command is available in DMs with the app, only for globally-scoped
/// commands. By default, commands are visible.
#[serde(default)]
#[deprecated = "Use Command::contexts"]
pub dm_permission: Option<bool>,
/// Indicates whether the command is [age-restricted](https://discord.com/developers/docs/interactions/application-commands#agerestricted-commands),
/// defaults to false.
#[serde(default)]
Expand Down
28 changes: 1 addition & 27 deletions src/model/application/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use serde_json::from_value;
use super::InstallationContext;
use super::{CommandInteraction, ComponentInteraction, ModalInteraction, PingInteraction};
use crate::internal::prelude::*;
use crate::model::guild::PartialMember;
use crate::model::id::{ApplicationId, InteractionId};
#[cfg(feature = "unstable")]
use crate::model::id::{GuildId, MessageId, UserId};
use crate::model::monetization::Entitlement;
#[cfg(feature = "unstable")]
use crate::model::user::User;
use crate::model::utils::deserialize_val;
#[cfg(feature = "unstable")]
Expand Down Expand Up @@ -395,32 +395,6 @@ impl serde::Serialize for AuthorizingIntegrationOwners {
}
}

/// Sent when a [`Message`] is a response to an [`Interaction`].
///
/// [`Message`]: crate::model::channel::Message
///
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object).
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "Use Message::interaction_metadata")]
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct MessageInteraction {
/// The id of the interaction.
pub id: InteractionId,
/// The type of the interaction.
#[serde(rename = "type")]
pub kind: InteractionType,
/// The name of the [`Command`].
///
/// [`Command`]: crate::model::application::Command
pub name: FixedString<u8>,
/// The user who invoked the interaction.
pub user: User,
/// The member who invoked the interaction in the guild.
#[serde(skip_serializing_if = "Option::is_none")]
pub member: Option<PartialMember>,
}

/// Metadata about the interaction, including the source of the interaction relevant server and
/// user IDs.
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
Expand Down
5 changes: 0 additions & 5 deletions src/model/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ pub struct Team {
pub struct TeamMember {
/// The member's membership state.
pub membership_state: MembershipState,
/// The list of permissions of the member on the team.
///
/// NOTE: Will always be "*" for now.
#[deprecated = "This field is not sent by the API anymore"]
pub permissions: FixedArray<String>,
/// The ID of the team they are a member of.
pub team_id: GenericId,
/// The user type of the team member.
Expand Down
21 changes: 0 additions & 21 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ pub struct Message {
pub flags: Option<MessageFlags>,
/// The message that was replied to using this message.
pub referenced_message: Option<Box<Message>>, // Boxed to avoid recursion
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "Use interaction_metadata")]
#[allow(deprecated)]
pub interaction: Option<Box<MessageInteraction>>,
/// Sent if the message is a response to an [`Interaction`].
///
/// [`Interaction`]: crate::model::application::Interaction
Expand Down Expand Up @@ -195,13 +192,6 @@ impl Message {
self.channel_id.to_channel(cache_http).await
}

/// A util function for determining whether this message was sent by someone else, or the bot.
#[cfg(feature = "cache")]
#[deprecated = "Check Message::author is equal to Cache::current_user"]
pub fn is_own(&self, cache: &Cache) -> bool {
self.author.id == cache.current_user().id
}

/// Deletes the message.
///
/// **Note**: The logged in user must either be the author of the message or have the [Manage
Expand Down Expand Up @@ -375,17 +365,6 @@ impl Message {
cache.guild(self.guild_id?)
}

/// True if message was sent using direct messages.
///
/// **Only use this for messages from the gateway (event handler)!** Not for returned Message
/// objects from HTTP requests, like [`ChannelId::send_message`], because [`Self::guild_id`] is
/// never set for those, which this method relies on.
#[must_use]
#[deprecated = "Check if guild_id is None if the message is received from the gateway."]
pub fn is_private(&self) -> bool {
self.guild_id.is_none()
}

/// Retrieves a clone of the author's Member instance, if this message was sent in a guild.
///
/// If the instance cannot be found in the cache, or the `cache` feature is disabled, a HTTP
Expand Down
19 changes: 0 additions & 19 deletions src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,6 @@ pub struct MessageUpdateEvent {
pub flags: Option<Option<MessageFlags>>,
#[serde(default, deserialize_with = "deserialize_some")]
pub referenced_message: Option<Option<Box<Message>>>,
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "Use interaction_metadata")]
#[serde(default, deserialize_with = "deserialize_some")]
#[allow(deprecated)]
pub interaction: Option<Option<Box<MessageInteraction>>>,
#[cfg(feature = "unstable")]
pub interaction_metadata: Option<Option<Box<MessageInteractionMetadata>>>,
#[serde(default, deserialize_with = "deserialize_some")]
Expand Down Expand Up @@ -568,7 +564,6 @@ impl MessageUpdateEvent {
message_reference,
flags,
referenced_message,
interaction,
#[cfg(feature = "unstable")]
interaction_metadata,
thread,
Expand Down Expand Up @@ -607,7 +602,6 @@ impl MessageUpdateEvent {
if let Some(x) = message_reference { message.message_reference.clone_from(x) }
if let Some(x) = flags { message.flags.clone_from(x) }
if let Some(x) = referenced_message { message.referenced_message.clone_from(x) }
if let Some(x) = interaction { message.interaction.clone_from(x) }
#[cfg(feature = "unstable")]
if let Some(x) = interaction_metadata { message.interaction_metadata.clone_from(x) }
if let Some(x) = thread { message.thread.clone_from(x) }
Expand All @@ -631,16 +625,6 @@ pub struct PresenceUpdateEvent {
pub presence: Presence,
}

/// Not officially documented.
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "This event doesn't exist")]
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(transparent)]
#[non_exhaustive]
pub struct PresencesReplaceEvent {
pub presences: FixedArray<Presence>,
}

/// Requires [`GatewayIntents::GUILD_MESSAGE_REACTIONS`] or
/// [`GatewayIntents::DIRECT_MESSAGE_REACTIONS`].
///
Expand Down Expand Up @@ -1244,9 +1228,6 @@ pub enum Event {
MessageUpdate(MessageUpdateEvent),
/// A member's presence state (or username or avatar) has changed
PresenceUpdate(PresenceUpdateEvent),
/// The presence list of the user's friends should be replaced entirely
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "This event doesn't exist")]
PresencesReplace(PresencesReplaceEvent),
/// A reaction was added to a message.
///
/// Fires the [`EventHandler::reaction_add`] event handler.
Expand Down
11 changes: 1 addition & 10 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::builder::{
};
#[cfg(feature = "collector")]
use crate::collector::{MessageCollector, ReactionCollector};
#[cfg(feature = "model")]
#[cfg(doc)]
use crate::constants::LARGE_THRESHOLD;
#[cfg(feature = "collector")]
use crate::gateway::ShardMessenger;
Expand Down Expand Up @@ -1388,15 +1388,6 @@ impl Guild {
self.id.invites(http).await
}

/// Checks if the guild is 'large'.
///
/// A guild is considered large if it has more than 250 members.
#[must_use]
#[deprecated = "Use Guild::large"]
pub fn is_large(&self) -> bool {
self.member_count > u64::from(LARGE_THRESHOLD)
}

/// Kicks a [`Member`] from the guild.
///
/// Requires the [Kick Members] permission.
Expand Down

0 comments on commit c74e396

Please sign in to comment.