问题
Currently working on a small bot which sends an embed and I want it to react to itself but am unsure on how to do that. Any help?
回答1:
Get the message you want to react to and use Client.add_reaction()
For example, if you're reacting to an embed
msg = await bot.send_message(ctx.message.channel,embed=embed)
await bot.add_reaction(msg, "😮")
回答2:
If you have this in your code
if message.author == client.user:
return
Your bot will not respond to itself, and it shouldn't respond to itself normally. A way around this would be to put any code you want to execute despite message.author == client.user
above it. For instance:
# This will respond to itself
if (message.content.lower() == "!yell"):
msg = "!yell"
await client.send_message(message.channel, msg)
# This checks to see if the author is the client
if message.author == client.user:
return
# This will not respond to itself
if (message.content.lower() == "!yell2"):
msg = "!yell"
await client.send_message(message.channel, msg)
!yell will result in your bot talking to itself until it reaches the message threshold, however, !yell2 will not because it come after the section that checks whether or not it's the client.user.
来源:https://stackoverflow.com/questions/54173483/how-to-make-discord-python-bot-react-to-its-own-message