Skip to content

unicode emoji as slash command argument #2513

Answered by BKSalman
BKSalman asked this question in Q&A
Discussion options

You must be logged in to vote

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 on Emoji, if that also fails, then I just return the error

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,
            )

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BKSalman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant