Skip to content

Commit

Permalink
Remove deprecated Member and Guild methods (serenity-rs#2817)
Browse files Browse the repository at this point in the history
Followup to serenity-rs#2816

---------

Co-authored-by: Alex M. M. <acdenissk69@gmail.com>
  • Loading branch information
2 people authored and mkrasnitski committed Jul 30, 2024
1 parent 12f9fc2 commit 1864312
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 52 deletions.
18 changes: 0 additions & 18 deletions src/model/guild/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 3 additions & 8 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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<UserId> {
#[must_use]
pub fn greater_member_hierarchy(&self, lhs_id: UserId, rhs_id: UserId) -> Option<UserId> {
// Check that the IDs are the same. If they are, neither is greater.
if lhs_id == rhs_id {
return None;
Expand Down
26 changes: 0 additions & 26 deletions src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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<UserId> {
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]
Expand Down

0 comments on commit 1864312

Please sign in to comment.