Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

discord.py add reaction to message

#1
message = ctx.send("text")
#2
message = channel.send("text")
#3
message = channel.fetch_message(messageid)
#add reaction to message
emoji = 'N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
Comment

discord.py check if message has certain reaction

emoji = "" # some emoji as a string
if any(reaction.emoji == emoji for reaction in message.reactions):
	# there is at least one reaction of the specified emoji
Comment

how to detect the reaction to a message discord.py

@client.event
async def on_message(message):
    #if the spotify command is triggered
        #fetch from the API
        spotifyEmbed = discord.Embed(title=resultName, ...)
        spotifyEmbed.set_image(url=spotifyImgUrl)
        spotifyMessage = await message.channel.send(embed=spotifyEmbed)
        await spotifyMessage.add_reaction("⬅️")
        await spotifyMessage.add_reaction("➡️")

@client.event
async def on_reaction_add(reaction, user):
    if user != client.user:
        if str(reaction.emoji) == "➡️":
            #fetch new results from the Spotify API
            newSearchResult = discord.Embed(...)
            await reaction.message.edit(embed=newSearchResult)
        if str(reaction.emoji) == "⬅️":
            #fetch new results from the Spotify API
            newSearchResult = discord.Embed(...)
            await reaction.message.edit(embed=newSearchResult)
Comment

how to add reaction by message id in discord.py

#react command
@bot.command()
@commands.has_permissions(manage_messages=True)
async def react(ctx,emoji,message_id):
  channel = ctx.channel
  msg = await channel.fetch_message(message_id)
  await msg.add_reaction(emoji)
Comment

get reactions from message discord.py

#Get reactions from cached msg
cache_msg = discord.utils.get(client.cached_messages, id=msg.id)
n_players = await cache_msg.reactions[0].users().flatten()
n_players = n_players[1:]
Comment

PREVIOUS NEXT
Code Example
Python :: python schedule task every hour 
Python :: how to combine strings python 
Python :: sys.maxsize in python 
Python :: dataframe fill nan with mode 
Python :: compare times python 
Python :: sql like equivalent in python 
Python :: pandas remove repeated index 
Python :: dict keys to list in python 
Python :: python - find columns that are objects 
Python :: django template add numbers 
Python :: python to make video 
Python :: csv file sort python 
Python :: how to input n space separated integers in python 
Python :: python cast to float 
Python :: code folding vim python 
Python :: what does % do in python 
Python :: how to filter queryset with foreign key in django 
Python :: python swap numbers 
Python :: uninstall python3 from source on centos 7 
Python :: how to rename files python 
Python :: python for loop with index 
Python :: puppy and sum codechef solution 
Python :: valid parentheses 
Python :: how to add subtitle to plot in python 
Python :: how to set numerecal index in pandas 
Python :: how to install httplib in python 
Python :: how to plot kmeans centroids 
Python :: convert integer to binary in python 
Python :: python tkinter ttk 
Python :: making your own range function in python 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =