Client Object¶
Clients¶
- class slack.Client(user_token: str, bot_token: str, token: Optional[str] = None, logger: Optional[Logger] = None, loop: Optional[AbstractEventLoop] = None, **options)¶
Create Client object from params. Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the
Client.- token¶
App-level token. It is startwith ‘xapp-…’
Changed in version 1.4.0: To optional.
- Type
Optional[
str]
- logger¶
Logger object.
New in version 1.4.0.
- Type
Logger.Logger
- loop¶
The
asyncio.AbstractEventLoopto use for asynchronous operations. Defaults toNone, in which case the default event loop is used viaasyncio.get_event_loop().- Type
Optional[
asyncio.AbstractEventLoop]
- @event¶
- event is a decorator that takes a coroutine function and sets
it as an attribute of the class it’s decorating.
- Parameters
coro (
Coro) – The coroutine function to be decorated.- Return type
The coro function itself.
- is_closed() bool¶
It returns a boolean value.
- Returns
The return value is a boolean value.
- Return type
- await on_error(event_name, exc: Exception, *args, **kwargs) None¶
It prints the name of the event that raised the exception, the name of the exception, and the name of the class that the event is in.
- Parameters
event_name – The name of the event that was raised.
exc (Exception) – The exception that was raised.
- run() None¶
A blocking call that abstracts away the event loop initialisation from you. If you want more control over the event loop then this function should not be used. Use
start()coroutine orconnect()+login(). Roughly Equivalent to:try: loop.run_until_complete(start(*args, **kwargs)) except KeyboardInterrupt: loop.run_until_complete(close()) # cancel all tasks lingering finally: loop.close()
Warning
This function must be the last function to call due to the fact that it is blocking. That means that registration of events or anything being called after this function call will not execute until it returns.