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

a "before_ready" event / signal if the bot needs to interact with the discord api on startup #71

Closed
leElvyn opened this issue Sep 2, 2021 · 2 comments
Labels
feature request New feature request

Comments

@leElvyn
Copy link

leElvyn commented Sep 2, 2021

Summary

An event similar to on_ready, that would be called once the bot has almost finished initializing, and everything is cached, but just before it starts receiving on_message events and sending commands

What is the feature request for?

The core library

The Problem

Some bots need to interact with the API when initializing, and this would provide an easy and safe way to make sure everything is ready before users can run any command, which could cause problems if some elements are missing.

The Ideal Solution

a simple blocking method that can would work similarly to on_ready, where the bot or client object would be available.
Example :

@commands.Cog.listener()
async def before_ready(self):
    emojis = self.bot.get_guild(self.emoji_guild_id).emojis

This is a minimalist example, but some bots need to cache elements before starting.
once the command returns, the bot will start listening for commands and messages

The Current Solution

currently, it is possible to add some checks at the start of every commands, that makes them return if it isn't initialized. However, this requires a check on every commands which can quickly be hard

Additional Context

No response

@leElvyn leElvyn added the feature request New feature request label Sep 2, 2021
@leElvyn leElvyn changed the title a "before_ready" event / signal if the bot needs to interact with the discord api a "before_ready" event / signal if the bot needs to interact with the discord api on startup Sep 2, 2021
@Rxann
Copy link

Rxann commented Sep 3, 2021

The bot should always need to interact with the discord api on startup because, it needs to connect to the websocket! Also, If you have anything in the on_ready event that requires interaction with the discord API!

@Dorukyum
Copy link
Member

Dorukyum commented Sep 5, 2021

The library only dispatches events supplied by the API. Also you can interact with the API under the CONNECT event which dispatches before READY.

@Dorukyum Dorukyum closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature request
Projects
None yet
Development

No branches or pull requests

3 participants