Search code examples
pythondiscorddiscord.pybots

On timeout logs


I am trying to make a moderation bot and I want it to log everything, I did everything but now how can I check if a member is given timeout, I searched up everything I could but didn't find anything please help me


Solution

  • According to the docs, you can check if a Member is timed out by looking at the timed_out_until attribute.

    So, if you want to track when a member is timed out, you can use the on_member_update event and check if the new member it's timed out.

    @bot.event
    async def on_member_update(before: discord.Member, after: discord.Member):
        if before.timed_out_until is None:
            if after.timed_out_until is not None:
                print(f"Member {after} was timed out!")