Skip to content

Add Client.run#16

Closed
Dark42ed wants to merge 2 commits into
stoatchat:masterfrom
Dark42ed:master
Closed

Add Client.run#16
Dark42ed wants to merge 2 commits into
stoatchat:masterfrom
Dark42ed:master

Conversation

@Dark42ed

Copy link
Copy Markdown

Discord.py has a run method for ease of access that automatically creates the asyncio loop and starts the client. I was thinking about adding that to here because it would help simplify the process of creating and running a bot.
Note: We could put the runner() method into the class such as _run_async instead of having it inside the run method.

@Dark42ed

Copy link
Copy Markdown
Author

This will simply the example code to this:

import revolt

class Client(revolt.Client):
    async def on_message(self, message: revolt.Message):
        if message.content == "hello":
            await message.channel.send("hi how are you")

client = Client()
client.run("BOT TOKEN HERE")

@Zomatree

Copy link
Copy Markdown
Member

Thanks, but no thanks, but i dont want to hide away the handling of the event loop from the user using this library, and i dont want to dynamically set the session on the client like this. asyncio.run already does a lot of event loop handling and i think that making an async main function is perfectly reasonable.

@Zomatree Zomatree closed this Sep 21, 2021
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