dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
680 stars 161 forks source link

on_ready event #410

Closed bmochan closed 1 year ago

bmochan commented 1 year ago

Summary

on_ready event fires way too long after the bot actually logs in

Reproduction Steps

It took about 2 minutes to output 'function fires', but I was able to run the 'ping' command as soon as I ran the program.

To reproduce the problem, just a simple on_ready event needs to be introduced.

Code

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('function fires')
        self.change_presence(status=discord.Status.dnd)
        print('Logged in', self.user)

    async def on_message(self, message):
        # only respond to ourselves
        if message.author != self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

client = MyClient()
client.run('mytoken')


### Expected Results

Event should fire as soon as the bot logs in.

### Actual Results

Event firing very late.

### System Information

Python v3.10.4-final
discord.py-self v1.9.2-final
aiohttp v3.7.4.post0
system info: Windows 10 10.0.22000

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shared the entire traceback.
- [X] I am using a user token (and it isn't visible in the code).

### Additional Information

_No response_
dolfies commented 1 year ago

This is due to the library attempting to populate the member caches of smallish guilds. Pass guild_subscription_options=GuildSubscriptionOptions.off() to the constructor or try the alpha.