Discord.py AFK 命令重写

Discord.py AFK Command Rewrite

这是我的 afk 命令:

@client.event
async def on_message(message):
    if message.mentions
    results = collection.find({"member": message.author.id}) 
    for result in results:
        collection.delete_one(result)
        if message.content == result:
            await message.channel.send(f"This person is currently AFK. \nFor: {reason}")
        

    await client.process_commands(message)

错误:

  File "main.py", line 124
    if message.mentions
                      ^
SyntaxError: invalid syntax

我对为什么有点困惑。有什么想法吗?

添加条件冒号:,

@client.event
async def on_message(message):
    if message.mentions:
        results = collection.find({"member": message.author.id}) 
        for result in results:
            collection.delete_one(result)
            if message.content == result:
                await message.channel.send(f"This person is currently AFK. \nFor: {reason}")
            

        await client.process_commands(message)