Skip to content

Conversation

@Toricane
Copy link
Contributor

@Toricane Toricane commented Jul 15, 2022

About

This pull request adds the on_start event.

Previous method of executing code when the bot is started:

started = False

@client.event
async def on_ready():
    global started
    if started:
        return
    started = True
    ...  # do stuff here

The PR implements this, which accomplishes the same thing:

async def on_start():
    ...  # do stuff here

Justification: most users do not check if the bot had started in their on_ready functions.
This would lead to it being dispatched multiple times, even though the majority wouldn't want it to.
Adding the on_start event mitigates this issue without breaking any functionality.

Checklist

  • I've ran pre-commit to format and lint the change(s) made.
  • I've checked to make sure the change(s) work on 3.8.6 and higher.
  • This fixes/solves an Issue.
    • (If existent):
  • I've made this pull request for/as: (check all that apply)
    • Documentation
    • Breaking change
    • New feature/enhancement
    • Bugfix

@Toricane Toricane changed the title Feat start event feat: on_start event Jul 15, 2022
@Toricane Toricane requested review from EepyElvyra and i0bs July 15, 2022 04:13
@Toricane Toricane enabled auto-merge (squash) July 15, 2022 04:14
@Toricane Toricane merged commit 2448567 into interactions-py:unstable Jul 15, 2022
@Toricane Toricane deleted the feat-start-event branch July 15, 2022 23:45
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