Discord.py - Make A Bot React To Its Own Message(s)
I am trying to make my discord bot react to its own message, pretty much. The system works like this: A person uses the command !!bug - And gets a message in DM', she/she is suppos
Solution 1:
In discord.py@rewrite, you have to use discord.Message.add_reaction
:
emojis = ['emoji 1', 'emoji_2', 'emoji 3']
adminBug = bot.get_channel(733721953134837861)
message = await adminBug.send(embed=embed)
for emoji in emojis:
await message.add_reaction(emoji)
Then, to exploit reactions, you'll have to use the discord.on_reaction_add
event. This event will be triggered when someone reacts to a message and will return a Reaction
object and a User
object:
@bot.eventasyncdefon_reaction_add(reaction, user):
embed = reaction.embeds[0]
emoji = reaction.emoji
if user.bot:
returnif emoji == "emoji 1":
fixed_channel = bot.get_channel(channel_id)
await fixed_channel.send(embed=embed)
elif emoji == "emoji 2":
#do stuffelif emoji == "emoji 3":
#do stuffelse:
return
NB: You'll have to replace "emoji 1"
, "emoji 2"
and "emoji 3"
with your emojis. add_reactions
accepts:
- Global emojis (eg. 😀) that you can copy on emojipedia
- Raw unicode (as you tried)
- Discord emojis:
\N{EMOJI NAME}
- Custom discord emojis (There might be some better ways, I've came up with this after a small amount a research)
asyncdefget_emoji(guild: discord.Guild, arg): return get(ctx.guild.emojis, name=arg)
Solution 2:
When you want to add non custom emojis you need to add its id and name into a format that discord.py can read: <:emoji name:emoji id>
For example, the white and green check emoji that is a discord default emoji...
you would need to write <:white_check_mark:824906654385963018>
for discord.py to be able to identify it.
Post a Comment for "Discord.py - Make A Bot React To Its Own Message(s)"