-
Hello! I'm trying to make a slash command (using poise) that would take any kind of emoji and later use a reaction, even tho there is how can I also include unicode emojis in the command? and would it make sense to also support that case in serenity directly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I ended up using emojis crate just to check if the thing passed in was actually a unicode emoji, then if it's not, try to parse it with the pub async fn some_command(
ctx: Context<'_>,
msg: serenity::Message,
emoji: String,
) -> Result<(), Error> {
match emojis::get(&emoji) {
Some(_unicode_emoji) => {
msg.react(ctx, ReactionType::Unicode(emoji.clone())).await?;
}
None => {
let emoji = Emoji::convert(
&ctx.serenity_context(),
ctx.guild_id(),
Some(ctx.channel_id()),
&emoji,
)
.await?;
msg.react(
ctx,
ReactionType::Custom {
animated: emoji.animated,
id: emoji.id,
name: Some(emoji.name),
},
)
.await?;
}
}
... if there is a better way to do this, please do tell :)! |
Beta Was this translation helpful? Give feedback.
I ended up using emojis crate just to check if the thing passed in was actually a unicode emoji, then if it's not, try to parse it with the
convert
function onEmoji
, if that also fails, then I just return the error