在我的 on_message 下,我有这个;
if message.channel.id == 809991898722861137:
emoji = client.get_emoji(830070201885130823)
await message.add_reaction(emoji)
emoji = client.get_emoji(830070201722601523)
await message.add_reaction(emoji)
emoji = client.get_emoji(830070202091175976)
await message.add_reaction(emoji)
emoji = client.get_emoji(830070201654837249)
await message.add_reaction(emoji)
但是每当我执行命令让我的机器人发送消息时,反应只会发布在我的消息上,而不是我的机器人上。
有什么办法可以让我的机器人消息中也有反应吗?
答案 0 :(得分:0)
我猜你希望对你的消息和机器人的消息都有反应。
import discord
from discord.ext import commands
import asyncio
client = commands.Bot(command_prefix=".")
@client.event
async def on_message(message):
if message.channel.id == 809991898722861137:
emoji = '\N{THUMBS UP SIGN}' # Thumbs up emoji
await message.add_reaction(emoji)
await client.process_commands(message)
或者,如果您只想在机器人上做出反应:
import discord
from discord.ext import commands
import asyncio
client = commands.Bot(command_prefix=".")
@client.event
async def on_message(message):
if message.channel.id == 809991898722861137:
if message.author == client.user: # Check if the message came from the bot
emoji = '\N{THUMBS UP SIGN}' # Thumbs up emoji
await message.add_reaction(emoji)
else:
# Do something else
await client.process_commands(message)