I've been trying to be able to asynchronously listen for events sent by discord to indicate a user's change of activity status (for example, if someone is listening to music on discord, it would track changes to the music they're listening to as they listen through a playlist, or it would trigger an event if the user starts playing a game)
I'm trying to do this using a discord bot, which would track this data for members of a given server (of which this bot is a part of, with administrative permissions). I enabled the privileged intents for the bot on the developer portal, since the on_presense_update event requires this. In my code, I specified the intents I want to listen to like this:
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix='>', itents=intents)
However, my event listener never picks up any changes to a user's presence (specifically, activity status updates); the following code never runs:
@client.event
async def on_presence_update(before, after):
#do something
Am I implementing this incorrectly, or am I using the wrong intent to accomplish what I'm trying to?
Please let me know if I'm not sharing the right details--I'm quite new to discord.py, and the world of intents and gateways in general!
It seems as though on_presence_update()
may be a deprecated method. Try using on_member_update()
instead, as per the discord.py documentation.