Discord Python API on_presence_update event handler not working

27 Views Asked by At

I gave my bot all permissions and added it to the server I want to use it in. When I run the example below all that prints out is the on_ready function and it never triggers the events on_presence_update, I tried using both commands.Cog.listener and tasks.loop decorators as well.

from discord.ext import tasks, commands

import discord
TOKEN = 'my_token'

class MyClient(discord.Client):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')

    # @tasks.loop(seconds=5)
    @commands.Cog.listener(name='on_presence_update')
    async def do_stuff(self, before, after): # also tried naming this to on_presence_update
        # await self.wait_until_ready()
        print(before.id) # never prints


client = MyClient(intents=discord.Intents.all())
client.run(TOKEN)

I'm also not sure what's up to date or not given there's around 3 python packages discord-py, discord and py-cord I tried all 3 so far and none of them works so I'm not sure what I'm doing wrong as many of the examples on stack overflow or google seem to be out dated.

0

There are 0 best solutions below