【发布时间】:2021-12-30 09:37:33
【问题描述】:
当您的消息与 bruh.txt 中的单词相同时,我想制作一个说 bruh 的机器人
我的代码:
bruh_file = open("bruh.txt", "r")
bruh_mo = [(line.strip()).split() for line in bruh_file]
bruh_file.close()
@client.event
async def on_message(message):
msg = message.content
if message.author == client.user:
return
if any(word in msg for word in bruh_mo):
await message.channel.send("bruh")
但是当我尝试它时,它没有响应,我得到了这个:
忽略 on_message 中的异常 回溯(最近一次通话最后): _run_event 中的文件“/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”,第 343 行 等待 coro(*args, **kwargs) on_message 中的文件“main.py”,第 53 行 如果有的话(味精中的单词对应bruh_mo中的单词): 文件“main.py”,第 53 行,在 如果有的话(味精中的单词对应bruh_mo中的单词): TypeError:'in'需要字符串作为左操作数,而不是列表 忽略 on_message 中的异常 回溯(最近一次通话最后): _run_event 中的文件“/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”,第 343 行 等待 coro(*args, **kwargs) on_message 中的文件“main.py”,第 53 行 如果有的话(味精中的单词对应bruh_mo中的单词): 文件“main.py”,第 53 行,在 如果有的话(味精中的单词对应bruh_mo中的单词): TypeError:'in'需要字符串作为左操作数,而不是列表 172.18.0.1 - - [30/Dec/2021 09:27:25] “头/HTTP/1.1”200 -
谁能帮帮我
【问题讨论】:
标签: python discord.py