Skip to content

Commit

Permalink
Remove deprecated items
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Dec 3, 2023
1 parent e84a363 commit a60990f
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 221 deletions.
14 changes: 0 additions & 14 deletions src/collector.rs
Original file line number Diff line number Diff line change
@@ -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 _};

Expand Down Expand Up @@ -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<Item = $item_type> {
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> {
Expand Down Expand Up @@ -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,
);
3 changes: 0 additions & 3 deletions src/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
26 changes: 0 additions & 26 deletions src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cache>,
role_id: impl Into<RoleId>,
) -> Result<Permissions> {
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.
Expand Down
4 changes: 0 additions & 4 deletions src/model/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 0 additions & 15 deletions src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
84 changes: 0 additions & 84 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Permissions> {
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<Permissions> {
// 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.
///
Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Permissions> {
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.
Expand Down
9 changes: 0 additions & 9 deletions src/model/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
39 changes: 0 additions & 39 deletions src/model/sticker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Http>, guild_id: impl Into<GuildId>) -> Result<()> {
guild_id.into().delete_sticker(http, self).await
}

/// Requests the sticker via the REST API to get a [`Sticker`] with all details.
///
/// # Errors
Expand All @@ -35,28 +18,6 @@ impl StickerId {
pub async fn to_sticker(self, http: impl AsRef<Http>) -> Result<Sticker> {
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<GuildId>,
builder: EditSticker<'_>,
) -> Result<Sticker> {
guild_id.into().edit_sticker(cache_http, self, builder).await
}
}

/// The smallest amount of data required to render a sticker.
Expand Down
15 changes: 0 additions & 15 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ pub fn parse_user_mention(mention: &str) -> Option<UserId> {
}
}

#[deprecated = "use `utils::parse_user_mention` instead"]
pub fn parse_username(mention: impl AsRef<str>) -> Option<UserId> {
parse_user_mention(mention.as_ref())
}

/// Retrieves an Id from a role mention.
///
/// If the mention is invalid, then [`None`] is returned.
Expand Down Expand Up @@ -191,11 +186,6 @@ pub fn parse_role_mention(mention: &str) -> Option<RoleId> {
}
}

#[deprecated = "use `utils::parse_role_mention` instead"]
pub fn parse_role(mention: impl AsRef<str>) -> Option<RoleId> {
parse_role_mention(mention.as_ref())
}

/// Retrieves an Id from a channel mention.
///
/// If the channel mention is invalid, then [`None`] is returned.
Expand Down Expand Up @@ -235,11 +225,6 @@ pub fn parse_channel_mention(mention: &str) -> Option<ChannelId> {
}
}

#[deprecated = "use `utils::parse_channel_mention` instead"]
pub fn parse_channel(mention: impl AsRef<str>) -> Option<ChannelId> {
parse_channel_mention(mention.as_ref())
}

/// Retrieves the animated state, name and Id from an emoji mention, in the form of an
/// [`EmojiIdentifier`].
///
Expand Down

0 comments on commit a60990f

Please sign in to comment.