Discord.py AFK 命令重写

时间:2021-04-21 03:14:57

标签: python python-3.x command discord.py client

这是我的 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

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

1 个答案:

答案 0 :(得分:0)

添加条件冒号 :,

@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)