I've been trying to make a bot using discord.py add a reaction to a message using discord.py after reading this (which is not what I wanted because I am not using custom emojis) but it ends up giving this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: message argument must be a Message
I tried this code
@commands.command(pass_context=True)
async def emoji(ctx):
msg = "working"
await bot.say(msg)
reactions = ['dart']
for emoji in reactions: await bot.add_reaction(msg, emoji)
Any other related questions here on discord.py are just not helpful for this Any ideas on how to implement this
The error message is telling you what the error is: "message argument must be a Message
"
In the line
await bot.add_reaction(msg, emoji)
msg
is a string, not a Message
object. You need to capture the message you send and then add the reactions to that message:
@commands.command(pass_context=True)
async def emoji(ctx):
msg = await bot.say("working")
reactions = ['dart']
for emoji in reactions:
await bot.add_reaction(msg, emoji)
Note that in later versions of discord.py
, add_reaction
has changed from bot.add_reaction(msg, emoji)
to await msg.add_reaction(emoji)
.