Skip to content

Commit

Permalink
Remove broken Message::super_react (serenity-rs#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbt365 authored Nov 26, 2024
1 parent 4b9756c commit d6b9b28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 67 deletions.
27 changes: 3 additions & 24 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,12 @@ impl Http {
.await
}

async fn create_reaction_(
/// Reacts to a message.
pub async fn create_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
reaction_type: &ReactionType,
burst: bool,
) -> Result<()> {
self.wind(204, Request {
body: None,
Expand All @@ -853,31 +853,10 @@ impl Http {
message_id,
reaction: &reaction_type.as_data(),
},
params: Some(vec![("burst", burst.to_string())]),
params: None,
})
.await
}

/// Reacts to a message.
pub async fn create_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
reaction_type: &ReactionType,
) -> Result<()> {
self.create_reaction_(channel_id, message_id, reaction_type, false).await
}

/// Super reacts to a message.
pub async fn create_super_reaction(
&self,
channel_id: ChannelId,
message_id: MessageId,
reaction_type: &ReactionType,
) -> Result<()> {
self.create_reaction_(channel_id, message_id, reaction_type, true).await
}

/// Creates a role.
pub async fn create_role(
&self,
Expand Down
47 changes: 4 additions & 43 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,35 +573,13 @@ impl Message {
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>,
) -> Result<Reaction> {
self.react_(cache_http, reaction_type.into(), false).await
}

/// React to the message with a custom [`Emoji`] or unicode character.
///
/// **Note**: Requires [Add Reactions] and [Use External Emojis] permissions.
///
/// # Errors
///
/// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user
/// does not have the required [permissions].
///
/// [Add Reactions]: Permissions::ADD_REACTIONS
/// [Use External Emojis]: Permissions::USE_EXTERNAL_EMOJIS
/// [permissions]: crate::model::permissions
#[inline]
pub async fn super_react(
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>,
) -> Result<Reaction> {
self.react_(cache_http, reaction_type.into(), true).await
self.react_(cache_http, reaction_type.into()).await
}

async fn react_(
&self,
cache_http: impl CacheHttp,
reaction_type: ReactionType,
burst: bool,
) -> Result<Reaction> {
#[cfg_attr(not(feature = "cache"), allow(unused_mut))]
let mut user_id = None;
Expand All @@ -615,30 +593,13 @@ impl Message {
self.channel_id,
Permissions::ADD_REACTIONS,
)?;

if burst {
utils::user_has_perms_cache(
cache,
self.channel_id,
Permissions::USE_EXTERNAL_EMOJIS,
)?;
}
}

user_id = Some(cache.current_user().id);
}
}

let reaction_types = if burst {
cache_http
.http()
.create_super_reaction(self.channel_id, self.id, &reaction_type)
.await?;
ReactionTypes::Burst
} else {
cache_http.http().create_reaction(self.channel_id, self.id, &reaction_type).await?;
ReactionTypes::Normal
};
cache_http.http().create_reaction(self.channel_id, self.id, &reaction_type).await?;

Ok(Reaction {
channel_id: self.channel_id,
Expand All @@ -648,9 +609,9 @@ impl Message {
guild_id: self.guild_id,
member: self.member.as_deref().map(|member| member.clone().into()),
message_author_id: None,
burst,
burst: false,
burst_colours: None,
reaction_type: reaction_types,
reaction_type: ReactionTypes::Normal,
})
}

Expand Down

0 comments on commit d6b9b28

Please sign in to comment.