0
votes

I'm making a discord python bot code that if i react with a emoji, the bot will send a message on the channel.

async def on_reaction_add(reaction, user):
    if (reaction.emoji == '\N{VICTORY HAND}'):
        await message.channel.send('hello')

But I cant send the message... (I'm terrible at English.. sorry)

1
Your English is fine! It would be easier to help you, if you wrote more details about "cant send the message". Do you get some error? Or do you not know how to initiate the sending? Please be more explicit.Grzegorz Oledzki

1 Answers

0
votes

A couple of items to consider.

  1. Consider using on_raw_reaction_add instead of on_reaction_add to capture all message reactions, not only cached ones.
  2. For your emoji compare, you can use python's emoji.demojize() to get the text representation of the emoji. pypi emoji 0.5.4. Discord doesn't see the victory hand emoji as '\N{VICTORY HAND}' it is just :V:. If you hover over it, you will see.
  3. To send a message you need to set a channel.

Try:

import emoji

@client.event
async def on_raw_reaction_add(payload):
    if emoji.demojize(str(payload.emoji)) == ':victory_hand:':
        channel = client.get_channel(payload.channel_id)
        await channel.send('hello')