【发布时间】:2021-08-30 18:33:43
【问题描述】:
我目前正在为我的直播编写一个 Twitch 审核机器人,但我遇到了一些问题 - 它的自动模组部分无法正常工作。我根本不知道是什么让它不起作用。
这是我的代码:
@bot.event()
async def event_message(message):
print(f"Message detected:\nSender: {message.author.name}\nContent: {message.content}")
for word in banned_words:
if word in message.content.lower():
print("I deleted that message.")
await message.send(f"/timeout {message.author.name} 3s You sent a non-family-friendly word, but we're a family-friendly channel.")
await message.send("f ¦ [Purge, 3s TO]")
这就是控制台中出现的内容:
Message detected:
Sender: slend_k
Content: [the swear word I sent - I changed it because, well, it's a swear]
I deleted that message.
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/twitchio/client.py", line 190, in wrapped
await func(*args)
File "main.py", line 28, in event_message
await message.send(f"/timeout {message.author.name} 3s You sent a non-family-friendly word, but we're a family-friendly channel.")
AttributeError: 'Message' object has no attribute 'send'
我不知道是什么导致了这个问题,因为我知道message 确实具有send 属性。
我用ctx.send 尝试过,但在控制台中给了我同样的错误。
感谢您提供的任何帮助! :D
【问题讨论】: