From a818c36b142d22c051df42abb0dad05c6409048b Mon Sep 17 00:00:00 2001 From: Gnome! Date: Tue, 26 Mar 2024 06:20:26 +0000 Subject: [PATCH] Remove deprecated `Member` and `Guild` methods (#2817) Followup to #2816 --------- Co-authored-by: Alex M. M. --- src/model/guild/member.rs | 18 ------------------ src/model/guild/mod.rs | 11 +++-------- src/model/guild/partial_guild.rs | 26 -------------------------- 3 files changed, 3 insertions(+), 52 deletions(-) diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index fbdf5c8be48..0feebb0fcb7 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -260,24 +260,6 @@ impl Member { Ok(()) } - /// Retrieves the ID and position of the member's highest role in the hierarchy, if they have - /// one. - /// - /// This _may_ return [`None`] if the user has roles, but they are not present in the cache for - /// cache inconsistency reasons. - /// - /// The "highest role in hierarchy" is defined as the role with the highest position. If two or - /// more roles have the same highest position, then the role with the lowest ID is the highest. - #[cfg(feature = "cache")] - #[deprecated = "Use Guild::member_highest_role"] - pub fn highest_role_info(&self, cache: &Cache) -> Option<(RoleId, i16)> { - cache - .guild(self.guild_id) - .as_ref() - .and_then(|g| g.member_highest_role(self)) - .map(|r| (r.id, r.position)) - } - /// Kick the member from the guild. /// /// **Note**: Requires the [Kick Members] permission. diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 4f1f892b30d..4855dd00f1e 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -362,7 +362,7 @@ impl Guild { fn check_hierarchy(&self, cache: &Cache, other_user: UserId) -> Result<()> { let current_id = cache.current_user().id; - if let Some(higher) = self.greater_member_hierarchy(cache, other_user, current_id) { + if let Some(higher) = self.greater_member_hierarchy(other_user, current_id) { if higher != current_id { return Err(Error::Model(ModelError::Hierarchy)); } @@ -1302,13 +1302,8 @@ impl Guild { /// owner, their ID is returned. /// /// [`position`]: Role::position - #[cfg(feature = "cache")] - pub fn greater_member_hierarchy( - &self, - #[allow(unused_variables)] cache: &Cache, - lhs_id: UserId, - rhs_id: UserId, - ) -> Option { + #[must_use] + pub fn greater_member_hierarchy(&self, lhs_id: UserId, rhs_id: UserId) -> Option { // Check that the IDs are the same. If they are, neither is greater. if lhs_id == rhs_id { return None; diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index a57d3a0eec7..a42c07a13e6 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -15,8 +15,6 @@ use crate::builder::{ EditRole, EditSticker, }; -#[cfg(all(feature = "cache", feature = "utils", feature = "client"))] -use crate::cache::Cache; #[cfg(feature = "collector")] use crate::collector::{MessageCollector, ReactionCollector}; #[cfg(feature = "collector")] @@ -898,30 +896,6 @@ impl PartialGuild { guild_id.to_partial_guild(cache_http).await } - /// Returns which of two [`User`]s has a higher [`Member`] hierarchy. - /// - /// Hierarchy is essentially who has the [`Role`] with the highest [`position`]. - /// - /// Returns [`None`] if at least one of the given users' member instances is not present. - /// Returns [`None`] if the users have the same hierarchy, as neither are greater than the - /// other. - /// - /// If both user IDs are the same, [`None`] is returned. If one of the users is the guild - /// owner, their ID is returned. - /// - /// [`position`]: Role::position - #[cfg(feature = "cache")] - #[deprecated = "Use Cache::guild and Guild::greater_member_hierarchy"] - pub fn greater_member_hierarchy( - &self, - cache: &Cache, - lhs_id: UserId, - rhs_id: UserId, - ) -> Option { - let guild = cache.guild(self.id)?; - guild.greater_member_hierarchy(cache, lhs_id, rhs_id) - } - /// Calculate a [`Member`]'s permissions in the guild. #[cfg(feature = "cache")] #[must_use]