Search code examples
pythonpython-3.xcommanddiscord.pyclient

Discord.py AFK Command Rewrite


Here is my afk command:

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

Error:

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

I was a little confused on why. any ideas?


Solution

  • Add the conditional colon :,

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