我目前正在为我的流编写一个Twitch调节机器人,我遇到了一个小问题——它的automod部分不起作用。我根本不知道是什么使它不起作用
这是我的密码:
@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
不幸的是,Twitch IO不支持在没有ctx的频道中发送消息。如果这只是为了缓和您的聊天,这里有一个涉及websocket客户端的解决方案:
如果您只是在任何时候运行该函数,您想让某人超时,它应该可以做到这一点!这是一个问题,我也有一段时间,所以我理解的挫折
相关问题 更多 >
编程相关推荐