This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
HivenClient ContextManager #73
Labels
concept
Logical Concept for OpenHiven.py
enhancement
New feature or request
request
Request for information or a feature
General Concept:
The idea behind using a ContextManager with a HivenClient is to be able to quickly use the Client and interact with the Hiven-API without having to focus too much on Event-listening or running it correctly. Still, more that you start the bot, run code and then the bot will stop as soon as the code finished you wanted to execute.
This could be useful for small interactions and quick changes, mainly consisting of a few lines, which can be then quickly executed. To that, if a user just wants to await something with
HivenClient.wait_for('on_message_create')
, they could do that in a few lines and then immediately stop the bot with a nice and more concise syntax.on_ready
andon_init
won't be usable with that syntax since__aenter__
only returns when the Client received the ready state.Usage:
Changes:
__aenter__
and__aexit__
which will run and stop the bot.__aenter__
will then need to return when the ready function was called running parallel to the websocket.token
as a static parameter to the HivenClient, which will make it not needed to provide a token onHivenClient.run()
, but directly on constructionThe text was updated successfully, but these errors were encountered: