fabian silva
fabian silva

Reputation: 55

how to use a costume emoji on a awaiting reaction?

I did this but when i put a custom emoji it doesn't work, it only works with unicode emojis.

message.react('707879839943753758').then(() => message.react('👎'));

const filter = (reaction, user) => {
    return ['707879839943753758', '👎'].includes(reaction.emoji.name) && user.id === message.author.id;
};

message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then(collected => {
        const reaction = collected.first();

        if (reaction.emoji.name === '707879839943753758') {
            message.reply('report something');
        } else {
            message.reply('did not report anything');
        }
    })
    .catch(collected => {
        message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
    });

what do i need to change in order for this to work??

Upvotes: 1

Views: 157

Answers (1)

Syntle
Syntle

Reputation: 5174

You need to get() the custom emoji before using it by accessing the client's emojis collection and getting the custom emoji:

const customEmoji = client.emojis.cache.get('707879839943753758');

message.react(customEmoji).then(() => message.react('👎'));

const filter = (reaction, user) => {
    return user.id === message.author.id;
};

message.awaitReactions(filter, {
        max: 1,
        time: 60000,
        errors: ['time']
    })
    .then(collected => {
        const reaction = collected.first();

        if (reaction.emoji.id === customEmoji.id) {
            message.reply('report something');
        }
        if (reaction.emoji.name === '👎') {
            message.reply('did not report anything');
        }
    })
    .catch(collected => {
        message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
    });

Upvotes: 1

Related Questions