我正在做一个不和谐的机器人和“坏话”的自动调节器

2024-06-17 13:18:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一个关于YT的教程的自动版主,它不起作用…我看着教程纠正了我的错误,它仍然不起作用,你能帮我吗?你知道吗


@client.event
async def check_curses(message):
    if any([curse in message.content.lower() for curse in CURSES]):
          await message.delete()
          await message.channel.send(f"{message.author.mention}, nie używaj tutaj takiego słownictwa!")
          return True
        return False```

I don't know what to do!

Tags: inclienteventmessageasyncreturndefcheck
1条回答
网友
1楼 · 发布于 2024-06-17 13:18:20

试着这样开始吧。它用on_message()监视所有消息

另外,不要忘记您需要在bot的角色中正确设置权限。此外,只要打印到控制台时,诅咒被发现。你知道吗

@client.event
async def on_message(message):
    curse_words = ['badword1', 'badword2']
    if any(x in message.content.lower() for x in curse_words):
        print(f'Curse found')
        await message.delete()
        await message.channel.send(f"{message.author.mention}, nie używaj tutaj takiego słownictwa!")

结果:

enter image description here

相关问题 更多 >