How to add reaction to a file discord.py

0

I want to make a command (I think it should be a event), I have a "#art and creativity" channel in my discord server. Members upload from time to time. I like make that when some one add a image file it adds a heart reaction automatically.

If you have any idea how to do this, please let me know.

bots discord discord.py python
2021-11-23 16:11:56
1

2

This is relatively simple. Assuming you have the bot already setup and stuff, you can just check every message and see if it has an attachment. If so, add a reaction to it.

@bot.event
async def on_message(message):
    if message.attachments: # checks if message has any attachments
        await message.add_reaction(emoji) 

I believe emoji has to be unicode character. I did a quick search and this is a heart in discord: \U00002764

2021-11-23 18:15:09

But how can I do that to a specific channel?
Candy Cat

The easiest way to a limit a bot to one channel is just to give it a role, maybe something like bot, and just only give it access to send permissions in one channel. You can do this by going to each channel, go to the settings, and changing the permissions. Here is a more detailed how to on that
Roopesh-J

It's a good way but , the bot have a lot of commands + he have administrator permission
Candy Cat

Ah ok, so you want this command specifically to only be in one channel? To do that you can use message.channel.name. So maybe your if statement would be if message.attachments and message.channel.name == 'general':.
Roopesh-J

Ohh. Thank you sooooo much!!
Candy Cat

No worries, good luck!
Roopesh-J

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................