I know how to make a bot react to a message, but I am stuck with my project and I'm just running constantly into troubles. I want to do a command with the syntax -react [message ID] [emote1] [emote2] [emote 3] [emote ...]
that reacts to the message belonging to the ID with the emotes I put after the ID.
I know how to make the bot react with the same emotes to always the same message, and tried to make it react to other messages with the code:
@client.command()
async def react(ctx, ID):
emotes = ['❤️', '🏠']
msg = message.fetch_message(ID)
for emote in emotes:
await ctx.msg.add_reaction(emoji=emote)
but this always puts out NameError: name 'message' is not defined
in msg = message.fetch_message(ID)
, and additionally I have not the slightest idea how to make it work with own chosen emotes.
So, my main problems are:
Update: First problem solved, I simply needed to add
message_id = ID
msg = await ctx.fetch_message(message_id)
but I'm still stuck with making it react with user given emotes, not hard-coded ones.
message
variable, that's why it's throwing that error.ID
arg is a string, ids must be integersctx
doesn't have the attribute msg
it's message
Also to implement the emojis you can simply pass them as a tuple and go through them using a for loop.
@client.command()
async def react(ctx, ID: int, *emojis):
message = ctx.fetch_message(ID)
for emoji in emojis:
await message.add_reaction(emoji)
# Or if you want to add the reactions to the message which invoked the command
await ctx.message.add_reaction(emoji)