Python Discord bot shows online status but won't detect member activities

I’m having trouble with my Discord bot built in Python. The bot connects successfully and shows as online, but it’s not responding to member activity changes like I expected.

I want the bot to detect when users are playing specific games or listening to Spotify, then send them private messages. The bot responds to text messages fine, but the activity monitoring part doesn’t work at all.

Here’s my current code:

import discord

bot = discord.Client(intents=discord.Intents.default())

@bot.event
async def on_ready():
    print("Bot is ready!")

@bot.event
async def on_message(msg):
    if msg.content == "!test":
        await msg.channel.send("Bot working!")

@bot.event
async def on_member_update(old_member, new_member):
    if new_member.activity is not None:
        if str(new_member.activity) == 'Valorant':
            member = new_member
            await member.send("Stop playing games!")
        elif isinstance(new_member.activity, discord.Spotify):
            member = new_member
            await member.send("Nice music!")
            with open('dance.gif', 'rb') as gif_file:
                await member.send(file=discord.File(gif_file, 'dance.gif'))

bot.run('my_token_here')

What am I missing? The message commands work but member activity detection doesn’t trigger at all.

I encountered a similar frustration when building my first activity-monitoring bot. Beyond the intents issue others mentioned, there’s another gotcha that caught me off guard - the way Discord handles activity names isn’t always straightforward. When you’re checking str(new_member.activity) == 'Valorant', Discord might be returning something like “Playing Valorant” or the activity name could have different capitalization. I had to switch to using new_member.activity.name.lower() and checking if ‘valorant’ was in that string instead of doing an exact match. Also worth noting that some games don’t always register immediately when users start playing, so there can be delays in detection. The presence intent is definitely your main issue here, but once you fix that, you might need to adjust your string matching logic to catch activities more reliably.

yeah, you gotta enable intents for presences, man. try using discord.Intents.all() or just set presences=True in your intents. they made it stricter for privacy. gotta make sure ur bot’s set up right!

The issue is definitely with your intents configuration. Discord requires explicit permission to access member presence data, which includes activity information. You need to enable the presence intent in your code by replacing discord.Intents.default() with something like intents = discord.Intents.default() then intents.presences = True before passing it to your client. However, there’s another crucial step that many people miss - you also need to enable the “Presence Intent” in your bot’s settings on the Discord Developer Portal. Without both the code change and the portal setting enabled, the on_member_update event simply won’t fire for activity changes. I ran into this exact problem when I first started working with Discord bots and spent hours debugging before realizing I had forgotten the portal configuration step.