我想让机器人对特定频道中的每条消息做出反应,这是我的代码:
@bot.event
async def on_message(message):
channel = bot.get_channel(837590298435649537)
if message in channel:
await message.add_reaction("✅")
这是错误:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 15, in on_message
if message in channel:
TypeError: argument of type 'TextChannel' is not iterable
我不知道怎么回事,请帮忙
答案 0 :(得分:3)
你不能使用 message in channel
你必须使用
if message.channel == channel:
await message.add_reaction("✅")