Skip to content

Commit 32c7e88

Browse files
committed
Remove more deprecated items (#2651)
1 parent 38ca4f8 commit 32c7e88

File tree

5 files changed

+0
-149
lines changed

5 files changed

+0
-149
lines changed

src/model/guild/emoji.rs

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
use std::fmt;
22

3-
#[cfg(all(feature = "cache", feature = "model"))]
4-
use crate::cache::Cache;
5-
#[cfg(all(feature = "cache", feature = "model"))]
6-
use crate::http::CacheHttp;
7-
#[cfg(all(feature = "cache", feature = "model"))]
8-
use crate::internal::prelude::*;
9-
#[cfg(all(feature = "cache", feature = "model"))]
10-
use crate::model::id::GuildId;
113
use crate::model::id::{EmojiId, RoleId};
124
use crate::model::user::User;
135
use crate::model::utils::default_true;
14-
#[cfg(all(feature = "cache", feature = "model"))]
15-
use crate::model::ModelError;
166

177
/// Represents a custom guild emoji, which can either be created using the API, or via an
188
/// integration. Emojis created using the API only work within the guild it was created in.
@@ -54,115 +44,6 @@ pub struct Emoji {
5444

5545
#[cfg(feature = "model")]
5646
impl Emoji {
57-
/// Deletes the emoji. This method requires the cache to fetch the guild ID.
58-
///
59-
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
60-
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
61-
/// Expressions] permission is required.
62-
///
63-
/// # Examples
64-
///
65-
/// Delete a given emoji:
66-
///
67-
/// ```rust,no_run
68-
/// # use serenity::client::Context;
69-
/// # use serenity::model::prelude::Emoji;
70-
/// #
71-
/// # async fn example(ctx: &Context, emoji: Emoji) -> Result<(), Box<dyn std::error::Error>> {
72-
/// // assuming emoji has been set already
73-
/// match emoji.delete(&ctx).await {
74-
/// Ok(()) => println!("Emoji deleted."),
75-
/// Err(_) => println!("Could not delete emoji."),
76-
/// }
77-
/// # Ok(())
78-
/// # }
79-
/// ```
80-
///
81-
/// # Errors
82-
///
83-
/// Returns [`Error::Http`] if the current user lacks permission, or may return
84-
/// [`ModelError::ItemMissing`] if the emoji is not in the cache.
85-
///
86-
/// [Create Guild Expressions]: crate::model::Permissions::CREATE_GUILD_EXPRESSIONS
87-
/// [Manage Guild Expressions]: crate::model::Permissions::MANAGE_GUILD_EXPRESSIONS
88-
#[deprecated = "Use Guild(Id)::delete_emoji, this performs a loop over all guilds!"]
89-
#[cfg(feature = "cache")]
90-
#[allow(deprecated)]
91-
#[inline]
92-
pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()> {
93-
let guild_id = self.try_find_guild_id(&cache_http)?;
94-
guild_id.delete_emoji(cache_http.http(), self).await
95-
}
96-
97-
/// Edits the emoji by updating it with a new name. This method requires the cache to fetch the
98-
/// guild ID.
99-
///
100-
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
101-
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
102-
/// Expressions] permission is required.
103-
///
104-
/// # Errors
105-
///
106-
/// Returns [`Error::Http`] if the current user lacks permission, or if an invalid name is
107-
/// given.
108-
///
109-
/// [Create Guild Expressions]: crate::model::Permissions::CREATE_GUILD_EXPRESSIONS
110-
/// [Manage Guild Expressions]: crate::model::Permissions::MANAGE_GUILD_EXPRESSIONS
111-
#[deprecated = "Use Guild(Id)::edit_emoji, this performs a loop over all guilds!"]
112-
#[cfg(feature = "cache")]
113-
#[allow(deprecated)]
114-
pub async fn edit(&mut self, cache_http: impl CacheHttp, name: &str) -> Result<()> {
115-
let guild_id = self.try_find_guild_id(&cache_http)?;
116-
*self = guild_id.edit_emoji(cache_http.http(), self.id, name).await?;
117-
Ok(())
118-
}
119-
120-
/// Finds the [`Guild`] that owns the emoji by looking through the Cache.
121-
///
122-
/// [`Guild`]: super::Guild
123-
///
124-
/// # Examples
125-
///
126-
/// Print the guild id that owns this emoji:
127-
///
128-
/// ```rust,no_run
129-
/// # use serenity::cache::Cache;
130-
/// # use serenity::model::guild::Emoji;
131-
/// #
132-
/// # fn run(cache: Cache, emoji: Emoji) {
133-
/// // assuming emoji has been set already
134-
/// if let Some(guild_id) = emoji.find_guild_id(&cache) {
135-
/// println!("{} is owned by {}", emoji.name, guild_id);
136-
/// }
137-
/// # }
138-
/// ```
139-
#[deprecated = "This performs a loop over all guilds and should not be used."]
140-
#[cfg(feature = "cache")]
141-
#[allow(deprecated)]
142-
#[must_use]
143-
pub fn find_guild_id(&self, cache: impl AsRef<Cache>) -> Option<GuildId> {
144-
for guild_entry in cache.as_ref().guilds.iter() {
145-
let guild = guild_entry.value();
146-
147-
if guild.emojis.contains_key(&self.id) {
148-
return Some(guild.id);
149-
}
150-
}
151-
152-
None
153-
}
154-
155-
#[deprecated = "This performs a loop over all guilds and should not be used."]
156-
#[cfg(feature = "cache")]
157-
#[allow(deprecated)]
158-
#[inline]
159-
fn try_find_guild_id(&self, cache_http: impl CacheHttp) -> Result<GuildId> {
160-
cache_http
161-
.cache()
162-
.and_then(|c| self.find_guild_id(c))
163-
.ok_or(Error::Model(ModelError::ItemMissing))
164-
}
165-
16647
/// Generates a URL to the emoji's image.
16748
///
16849
/// # Examples

src/model/guild/guild_id.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ impl GuildId {
601601

602602
/// Edits an [`Emoji`]'s name in the guild.
603603
///
604-
/// Also see [`Emoji::edit`] if you have the `cache` and `methods` features enabled.
605-
///
606604
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
607605
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
608606
/// Expressions] permission is required.

src/model/guild/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,6 @@ impl Guild {
10981098

10991099
/// Edits an [`Emoji`]'s name in the guild.
11001100
///
1101-
/// Also see [`Emoji::edit`] if you have the `cache` and `model` features enabled.
1102-
///
11031101
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
11041102
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
11051103
/// Expressions] permission is required.

src/model/guild/partial_guild.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,6 @@ impl PartialGuild {
784784

785785
/// Edits an [`Emoji`]'s name in the guild.
786786
///
787-
/// Also see [`Emoji::edit`] if you have the `cache` and `methods` features enabled.
788-
///
789787
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
790788
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
791789
/// Expressions] permission is required.

src/model/guild/role.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use std::fmt;
33

44
#[cfg(feature = "model")]
55
use crate::builder::EditRole;
6-
#[cfg(all(feature = "cache", feature = "model"))]
7-
use crate::cache::Cache;
86
#[cfg(feature = "model")]
97
use crate::http::Http;
108
#[cfg(all(feature = "cache", feature = "model"))]
@@ -160,28 +158,6 @@ impl PartialOrd for Role {
160158
}
161159
}
162160

163-
#[cfg(feature = "model")]
164-
impl RoleId {
165-
/// Tries to find the [`Role`] by its Id in the cache.
166-
#[cfg(feature = "cache")]
167-
#[deprecated = "Use Guild::roles. This performs a loop over the entire cache!"]
168-
pub fn to_role_cached(self, cache: impl AsRef<Cache>) -> Option<Role> {
169-
for guild_entry in cache.as_ref().guilds.iter() {
170-
let guild = guild_entry.value();
171-
172-
if !guild.roles.contains_key(&self) {
173-
continue;
174-
}
175-
176-
if let Some(role) = guild.roles.get(&self) {
177-
return Some(role.clone());
178-
}
179-
}
180-
181-
None
182-
}
183-
}
184-
185161
impl From<Role> for RoleId {
186162
/// Gets the Id of a role.
187163
fn from(role: Role) -> RoleId {

0 commit comments

Comments
 (0)