Skip to content

Commit

Permalink
fix support for some emojis
Browse files Browse the repository at this point in the history
discord sends V16 for some reactions too apparently, go figure
  • Loading branch information
circuitsacul committed Jan 25, 2023
1 parent 95688eb commit 1f6e67b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use twilight_model::{

use crate::client::bot::StarboardBot;

fn clean_emoji(unicode: &str) -> &str {
unicode.strip_suffix('\u{fe0f}').unwrap_or(unicode)
}

#[derive(Clone)]
pub struct SimpleEmoji {
pub raw: String,
Expand Down Expand Up @@ -81,9 +85,7 @@ impl EmojiCommon for SimpleEmoji {
) -> Option<Self> {
// Get rid of the Variation-Selector-16 codepoint that is sometimes present in user
// input. https://emojipedia.org/variation-selector-16/
let input = input
.strip_suffix('\u{fe0f}')
.map_or_else(|| input.to_string(), |s| s.to_string());
let input = clean_emoji(&input).to_string();

if emojis::get(&input).is_some() {
Some(Self {
Expand Down Expand Up @@ -158,7 +160,7 @@ impl From<ReactionType> for SimpleEmoji {
as_id: Some(id),
},
ReactionType::Unicode { name } => SimpleEmoji {
raw: name,
raw: clean_emoji(&name).to_string(),
as_id: None,
},
}
Expand Down

0 comments on commit 1f6e67b

Please sign in to comment.