From a60990fc102c9e60ecec4bcd9e08c73967461076 Mon Sep 17 00:00:00 2001 From: David Thomas Date: Sun, 3 Dec 2023 18:16:34 +0000 Subject: [PATCH] Remove deprecated items --- src/collector.rs | 14 ----- src/http/request.rs | 3 -- src/model/channel/guild_channel.rs | 26 --------- src/model/channel/mod.rs | 4 -- src/model/event.rs | 1 - src/model/gateway.rs | 15 ------ src/model/guild/mod.rs | 84 ------------------------------ src/model/guild/partial_guild.rs | 11 ---- src/model/permissions.rs | 9 ---- src/model/sticker.rs | 39 -------------- src/utils/mod.rs | 15 ------ 11 files changed, 221 deletions(-) diff --git a/src/collector.rs b/src/collector.rs index bcec95e629d..a57f9c1fccc 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -1,6 +1,3 @@ -// Or we'll get deprecation warnings from our own deprecated type (seriously Rust?) -#![allow(deprecated)] - use futures::future::pending; use futures::{Stream, StreamExt as _}; @@ -127,12 +124,6 @@ macro_rules! make_specific_collector { stream.take_until(Box::pin(timeout)) } - /// Deprecated, use [`Self::stream()`] instead. - #[deprecated = "use `.stream()` instead"] - pub fn build(self) -> impl Stream { - self.stream() - } - #[doc = concat!("Returns the next [`", stringify!($item_type), "`] which passes the filters.")] #[doc = concat!("You can also call `.await` on the [`", stringify!($collector_type), "`] directly.")] pub async fn next(self) -> Option<$item_type> { @@ -195,8 +186,3 @@ make_specific_collector!( channel_id: ChannelId => message.channel_id == *channel_id, guild_id: GuildId => message.guild_id.map_or(true, |g| g == *guild_id), ); -make_specific_collector!( - #[deprecated = "prefer the stand-alone collect() function to collect arbitrary events"] - EventCollector, Event, - event => event, -); diff --git a/src/http/request.rs b/src/http/request.rs index 9961c01db81..bd3c0a7672f 100644 --- a/src/http/request.rs +++ b/src/http/request.rs @@ -17,9 +17,6 @@ use super::{HttpError, LightMethod}; use crate::constants; use crate::internal::prelude::*; -#[deprecated = "use Request directly now"] -pub type RequestBuilder<'a, Params> = Request<'a, Params>; - pub type NoParams = std::iter::Empty<(&'static str, String)>; #[derive(Clone, Debug)] diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index bb00d93d572..63501dfc3a7 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -766,32 +766,6 @@ impl GuildChannel { Ok(guild.user_permissions_in(self, member)) } - /// Calculates the permissions of a role. - /// - /// The Id of the argument must be a [`Role`] of the [`Guild`] that the channel is in. - /// - /// # Errors - /// - /// Returns a [`ModelError::GuildNotFound`] if the channel's guild could not be found in the - /// [`Cache`]. - /// - /// Returns a [`ModelError::RoleNotFound`] if the given role could not be found in the - /// [`Cache`]. - #[cfg(feature = "cache")] - #[inline] - #[deprecated = "this function ignores other roles the user may have as well as user-specific permissions; use Guild::user_permissions_in instead"] - #[allow(deprecated)] - pub fn permissions_for_role( - &self, - cache: impl AsRef, - role_id: impl Into, - ) -> Result { - let guild = self.guild(&cache).ok_or(Error::Model(ModelError::GuildNotFound))?; - let role = - guild.roles.get(&role_id.into()).ok_or(Error::Model(ModelError::RoleNotFound))?; - guild.role_permissions_in(self, role) - } - /// Pins a [`Message`] to the channel. /// /// **Note**: Requires the [Manage Messages] permission. diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 3078c309488..0acfe2f3f11 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -28,10 +28,6 @@ use crate::model::prelude::*; use crate::model::utils::is_false; use crate::model::Timestamp; -#[deprecated = "use CreateAttachment instead"] -#[cfg(feature = "model")] -pub type AttachmentType<'a> = crate::builder::CreateAttachment; - /// A container for any channel. #[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))] #[derive(Clone, Debug, Serialize)] diff --git a/src/model/event.rs b/src/model/event.rs index f09eda29a10..4907b6a7df6 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -541,7 +541,6 @@ impl MessageUpdateEvent { pub fn apply_to_message(&self, message: &mut Message) { // Destructure, so we get an `unused` warning when we forget to process one of the fields // in this method - #[allow(deprecated)] // yes rust, exhaustive means exhaustive, even the deprecated ones let Self { id, channel_id, diff --git a/src/model/gateway.rs b/src/model/gateway.rs index a2abfff084b..423edcf82b6 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -485,9 +485,6 @@ bitflags! { /// - GUILD_BAN_ADD /// - GUILD_BAN_REMOVE const GUILD_MODERATION = 1 << 2; - /// Backwards compatibility with old gateway event name. Same as GUILD_MODERATION - #[deprecated = "Use [`Self::GUILD_MODERATION`] instead"] - const GUILD_BANS = 1 << 2; /// Enables the following gateway events: /// - GUILD_EMOJIS_UPDATE @@ -620,18 +617,6 @@ impl GatewayIntents { self.contains(Self::GUILD_MEMBERS) } - /// Shorthand for checking that the set of intents contains the [GUILD_BANS] intent. - /// - /// [GUILD_BANS]: Self::GUILD_BANS - /// - /// This is the same as calling guild_moderation since Discord changed the name - #[must_use] - #[deprecated = "Use [`Self::guild_moderation`] instead"] - pub const fn guild_bans(self) -> bool { - #[allow(deprecated)] // this is a deprecated method itself - self.contains(Self::GUILD_BANS) - } - /// Shorthand for checking that the set of intents contains the [GUILD_MODERATION] intent. /// /// [GUILD_MODERATION]: Self::GUILD_MODERATION diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index e4f4d895782..840abf54b2d 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -1990,49 +1990,6 @@ impl Guild { }) } - /// Calculate a [`Role`]'s permissions in a given channel in the guild. - /// - /// # Errors - /// - /// Will return an [`Error::Model`] if the [`Role`] or [`Channel`] is not from this [`Guild`]. - #[inline] - #[deprecated = "this function ignores other roles the user may have as well as user-specific permissions; use user_permissions_in instead"] - pub fn role_permissions_in(&self, channel: &GuildChannel, role: &Role) -> Result { - Self::_role_permissions_in(channel, role, self.id) - } - - /// Helper function that can also be used from [`PartialGuild`]. - pub(crate) fn _role_permissions_in( - channel: &GuildChannel, - role: &Role, - guild_id: GuildId, - ) -> Result { - // Fail if the role or channel is not from this guild. - if role.guild_id != guild_id || channel.guild_id != guild_id { - return Err(Error::Model(ModelError::WrongGuild)); - } - - let mut permissions = role.permissions; - - if permissions.contains(Permissions::ADMINISTRATOR) { - return Ok(Self::remove_unnecessary_voice_permissions(channel, Permissions::all())); - } - - for overwrite in &channel.permission_overwrites { - if let PermissionOverwriteType::Role(permissions_role_id) = overwrite.kind { - if permissions_role_id == role.id { - permissions = (permissions & !overwrite.deny) | overwrite.allow; - - break; - } - } - } - - Self::remove_unusable_permissions(&mut permissions); - - Ok(permissions) - } - /// Retrieves the count of the number of [`Member`]s that would be pruned with the number of /// given days. /// @@ -2062,47 +2019,6 @@ impl Guild { self.id.prune_count(cache_http.http(), days).await } - pub(crate) fn remove_unusable_permissions(permissions: &mut Permissions) { - // No SEND_MESSAGES => no message-sending-related actions - // If the member does not have the `SEND_MESSAGES` permission, then throw out message-able - // permissions. - if !permissions.contains(Permissions::SEND_MESSAGES) { - *permissions &= !(Permissions::SEND_TTS_MESSAGES - | Permissions::MENTION_EVERYONE - | Permissions::EMBED_LINKS - | Permissions::ATTACH_FILES); - } - - // If the permission does not have the `VIEW_CHANNEL` permission, then throw out actionable - // permissions. - if !permissions.contains(Permissions::VIEW_CHANNEL) { - *permissions &= !(Permissions::KICK_MEMBERS - | Permissions::BAN_MEMBERS - | Permissions::ADMINISTRATOR - | Permissions::MANAGE_GUILD - | Permissions::CHANGE_NICKNAME - | Permissions::MANAGE_NICKNAMES); - } - } - - pub(crate) fn remove_unnecessary_voice_permissions( - channel: &GuildChannel, - mut permissions: Permissions, - ) -> Permissions { - // If this is a text channel, then throw out voice permissions. - if channel.kind == ChannelType::Text { - permissions &= !(Permissions::CONNECT - | Permissions::SPEAK - | Permissions::MUTE_MEMBERS - | Permissions::DEAFEN_MEMBERS - | Permissions::MOVE_MEMBERS - | Permissions::USE_VAD - | Permissions::STREAM); - } - - permissions - } - /// Re-orders the channels of the guild. /// /// Although not required, you should specify all channels' positions, regardless of whether diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index 4758b3a0978..f01067ecb58 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -1361,17 +1361,6 @@ impl PartialGuild { Guild::_user_permissions_in(Some(channel), member, &self.roles, self.owner_id, self.id) } - /// Calculate a [`Role`]'s permissions in a given channel in the guild. - /// - /// # Errors - /// - /// Returns [`Error::Model`] if the [`Role`] or [`Channel`] is not from this [`Guild`]. - #[inline] - #[deprecated = "this function ignores other roles the user may have as well as user-specific permissions; use user_permissions_in instead"] - pub fn role_permissions_in(&self, channel: &GuildChannel, role: &Role) -> Result { - Guild::_role_permissions_in(channel, role, self.id) - } - /// Gets the number of [`Member`]s that would be pruned with the given number of days. /// /// Requires the [Kick Members] permission. diff --git a/src/model/permissions.rs b/src/model/permissions.rs index 3e89df1dd02..3dee6b60748 100644 --- a/src/model/permissions.rs +++ b/src/model/permissions.rs @@ -319,8 +319,6 @@ bitflags::bitflags! { /// Allows for editing and deleting emojis, stickers, and soundboard sounds created by all /// users. const MANAGE_GUILD_EXPRESSIONS = 1 << 30; - #[deprecated = "use `Permissions::MANAGE_GUILD_EXPRESSIONS` instead"] - const MANAGE_EMOJIS_AND_STICKERS = 1 << 30; /// Allows members to use application commands, including slash commands and context menu /// commands. const USE_APPLICATION_COMMANDS = 1 << 31; @@ -593,13 +591,6 @@ impl Permissions { self.contains(Self::MANAGE_CHANNELS) } - #[deprecated = "use `manage_guild_expressions` instead"] - #[must_use] - pub const fn manage_emojis_and_stickers(self) -> bool { - #[allow(deprecated)] - self.contains(Self::MANAGE_EMOJIS_AND_STICKERS) - } - /// Shorthand for checking that the set of permissions contains the [Manage Events] permission. /// /// [Manage Events]: Self::MANAGE_EVENTS diff --git a/src/model/sticker.rs b/src/model/sticker.rs index 0283b7c883d..5459e08c0ba 100644 --- a/src/model/sticker.rs +++ b/src/model/sticker.rs @@ -9,23 +9,6 @@ use crate::model::utils::comma_separated_string; #[cfg(feature = "model")] impl StickerId { - /// Delete a guild sticker. - /// - /// **Note**: If the sticker was created by the current user, requires either the [Create Guild - /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild - /// Expressions] permission is required. - /// - /// # Errors - /// - /// Returns [`Error::Http`] if the current user lacks permission. - /// - /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS - /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS - #[deprecated = "use `GuildId::delete_sticker` instead"] - pub async fn delete(self, http: impl AsRef, guild_id: impl Into) -> Result<()> { - guild_id.into().delete_sticker(http, self).await - } - /// Requests the sticker via the REST API to get a [`Sticker`] with all details. /// /// # Errors @@ -35,28 +18,6 @@ impl StickerId { pub async fn to_sticker(self, http: impl AsRef) -> Result { http.as_ref().get_sticker(self).await } - - /// Edits the sticker. - /// - /// **Note**: If the sticker was created by the current user, requires either the [Create Guild - /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild - /// Expressions] permission is required. - /// - /// # Errors - /// - /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. - /// - /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS - /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS - #[deprecated = "use `GuildId::edit_sticker` instead"] - pub async fn edit( - self, - cache_http: impl CacheHttp, - guild_id: impl Into, - builder: EditSticker<'_>, - ) -> Result { - guild_id.into().edit_sticker(cache_http, self, builder).await - } } /// The smallest amount of data required to render a sticker. diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 6605424e522..e0272aab056 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -148,11 +148,6 @@ pub fn parse_user_mention(mention: &str) -> Option { } } -#[deprecated = "use `utils::parse_user_mention` instead"] -pub fn parse_username(mention: impl AsRef) -> Option { - parse_user_mention(mention.as_ref()) -} - /// Retrieves an Id from a role mention. /// /// If the mention is invalid, then [`None`] is returned. @@ -191,11 +186,6 @@ pub fn parse_role_mention(mention: &str) -> Option { } } -#[deprecated = "use `utils::parse_role_mention` instead"] -pub fn parse_role(mention: impl AsRef) -> Option { - parse_role_mention(mention.as_ref()) -} - /// Retrieves an Id from a channel mention. /// /// If the channel mention is invalid, then [`None`] is returned. @@ -235,11 +225,6 @@ pub fn parse_channel_mention(mention: &str) -> Option { } } -#[deprecated = "use `utils::parse_channel_mention` instead"] -pub fn parse_channel(mention: impl AsRef) -> Option { - parse_channel_mention(mention.as_ref()) -} - /// Retrieves the animated state, name and Id from an emoji mention, in the form of an /// [`EmojiIdentifier`]. ///