Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't process comands until extensions are loaded #190

Merged
merged 3 commits into from
Jul 25, 2023

Conversation

ChrisLovering
Copy link
Member

@ChrisLovering ChrisLovering commented Jul 25, 2023

This PR adds BotBase.wait_until_bot_started which can be used to hold a process until all extensions are loaded.
This will also wait until all app commands have synced, if sync_app_commands was set when calling BotBase.load_extensions.

I have also overwritten discord.ext.commands.Bot.process_commands to first call pydis_core.BotBase.wait_until_bot_started to ensure no commands are processed until all extensions are loaded.

@netlify
Copy link

netlify bot commented Jul 25, 2023

Deploy Preview for bot-core ready!

Name Link
🔨 Latest commit 2da733d
🔍 Latest deploy log https://app.netlify.com/sites/bot-core/deploys/64bfcbd67a3ef6000872013f
😎 Deploy Preview https://deploy-preview-190--bot-core.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ChrisLovering ChrisLovering force-pushed the wait_until_bot_started branch 2 times, most recently from 487f04f to b8bb6cf Compare July 25, 2023 10:59
@ChrisLovering ChrisLovering changed the title Add BotBase.wait_until_bot_started which can be used to hold a proces… Don't process comands until extensions are loaded Jul 25, 2023
Copy link
Member

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently throws TypeError: object NoneType can't be used in 'await' expression

The .set method is not async, so you shouldn't await it since calling it returns None instead of a coro.

@ChrisLovering
Copy link
Member Author

This currently throws TypeError: object NoneType can't be used in 'await' expression

The .set method is not a coro, so you shouldn't await it since calling it returns None.

Hah yea, my bad. Fixed in a fixup

Copy link
Member

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, thanks.

pydis_core/_bot.py Outdated Show resolved Hide resolved
pydis_core/_bot.py Show resolved Hide resolved
@shtlrs
Copy link
Member

shtlrs commented Jul 25, 2023

Thanks Chris !

@ChrisLovering ChrisLovering merged commit fc8af5e into main Jul 25, 2023
8 checks passed
@ChrisLovering ChrisLovering deleted the wait_until_bot_started branch July 25, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants