Skip to content
Discussion options

You must be logged in to vote

Unfortunately, as far as I am aware, I cannot do things such as bot.get_channel() before the bot has started. Either way, I also need to run async functions immediately when certain events are called.

I'm writing this in another comment because this is probably the answer you're looking for.

You could create something that acts similar to bot.wait_until_ready() using an asyncio.Event.

For example:

import asyncio
import discord

class MyBot(discord.Client):
    def __init__(self):
        super().__init__()
        self.my_event = asyncio.Event()

    async def wait_until_actually_ready(self):
        return await self.my_event.wait()

    async def on_ready(self):
        ... # do whate…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Mummified316
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Mummified316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants