Reputation: 5
To preface: I am VERY inexperienced with Python, and have never taken a class for it. This is my first time coding Python/making a discord bot.
Right here I have an embed that is triggered by a specific message. I am using a discord ticket bot (creates new channels that are private to a person who reacted to a message) already (plan to make my own in the future) and every time a new ticket is created, this embed is sent. I have seen posts on here about adding reactions to an embed, by referencing the channel id on the discord server, however I cannot do this. The embed is sent to a brand new channel every time I want reactions added. I'm not sure if I don't quite understand Python enough to actually do this, or if it actually CAN'T be done. Regardless, some help would be appreciated in trying to solve this. To be clear: I want to have reactions added along with every embed created (not in one specific channel but ones created on the fly).
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('Welcome to Parakeets Mods'):
embed = discord.Embed(title="Product Select", description="React to the emojis corresponding with what you need", color=0xE91E63)
embed.add_field(name="", value="<:dmu:841700430764310559> = ***-*** \n\n <:damascus:841700430492860466> = ***-*** \n\n <a:prestige10:841700430010777651> = ***-*** \n\n <:ruavt:856345494674472980> = ***-*** \n\n ❓ = ***Questions***")
await message.channel.send(embed=embed)
#insert add reaction to above embed
client.run(os.getenv('TOKEN'))
Upvotes: 0
Views: 4121
Reputation: 166
You can add reactions using the add_reaction("emoji_here")
. you also need to define the message the bot send to make it work.
Reference from the FAQ: https://discordpy.readthedocs.io/en/stable/faq.html#how-can-i-add-a-reaction-to-a-message
Updated Code :
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('Welcome to Parakeets Mods'):
embed = discord.Embed(title="Product Select", description="React to the emojis corresponding with what you need", color=0xE91E63)
embed.add_field(name="", value="<:dmu:841700430764310559> = ***-*** \n\n <:damascus:841700430492860466> = ***-*** \n\n <a:prestige10:841700430010777651> = ***-*** \n\n <:ruavt:856345494674472980> = ***-*** \n\n ❓ = ***Questions***")
embed_message = await message.channel.send(embed=embed)
await embed_message.add_reaction("😳")
client.run(os.getenv('TOKEN'))
Thank me later :D
Upvotes: 0
Reputation: 15728
You can define the message you're sending and add a reaction to it
msg = await message.channel.send(embed=embed)
await msg.add_reaction("✅")
PS: You have to pass a unicode emoji when adding a reaction, to get it \:emoji:
in discord, send and copy the message
Upvotes: 2