Client#
The Client
class is the core of this library that brings together everything needed
for building complex Revolt bots. It provides all the machinery in form a rich interface that
can be used to interact with Revolt API.
Client#
- class luster.Client(token: str, bot: bool = True, session: Optional[ClientSession] = None, http_handler_cls: Type[HTTPHandler] = <class 'luster.http.HTTPHandler'>, websocket_handler_cls: Type[WebsocketHandler] = <class 'luster.websocket.WebsocketHandler'>)#
A client that interacts with Revolt API.
This class provides a user friendly interface for interacting with Revolt Events and HTTP API. This class mainly focuses on automating user accounts or creating bots. If you intend to perform simple HTTP requests, Use
HTTPHandler
instead.- Parameters
token (
str
) – The bot or session token.bot (
bool
) – Whether the passedtoken
is a bot token. Set this toFalse
when a session token is passed (i.e for a user). Defaults toTrue
.session (Optional[
aiohttp.ClientSession
]) –The client session used for making HTTP requests.
If not provided, A session is created internally and would be closed automatically after usage. Note that when a session is provided by the user, It must be closed by the user. Library will not take it’s ownership.
http_handler_cls (Optional[Type[
HTTPHandler
]]) – The class type ofHTTPHandler
. This can be used to set custom subclasses onhttp_handler
.
- property http_handler: luster.http.HTTPHandler#
The HTTP handler associated to this client.
- Returns
- Return type
- launch() None #
Launches the bot.
This is a high level of
connect()
that handles asyncio event loop cleanup and provides a synchronous way of starting the client.Consider using
connect()
if you intend to have more control over the event loop.
- listen(event: EventTypeRecv) Callable[[Listener[BE]], Listener[BE]] #
A decorator for registering an event listener.
- Parameters
event (
types.EventTypeRecv
) – The event to listen to.
- property websocket_handler: luster.websocket.WebsocketHandler#
The websocket handler associated to this client.
- Returns
- Return type