Client Object¶
Clients¶
- class slack.Client(user_token: str, bot_token: str, token: str | None = None, logger: ~logging.Logger | None = None, log_level: int = 20, log_format: ~logging.Formatter | None = None, loop: ~asyncio.events.AbstractEventLoop | None = None, logger_option: ~slack.client.LoggerOption = <slack.client.LoggerOption object>, **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.- Parameters:
user_token (
str) – The your-self token. It must be start ‘xoxp-…’bot_token (
str) – The bot token. It must be start ‘xoxb-…’token (Optional[
str]) –App-level token. It is startwith ‘xapp-…’
Changed in version 1.4.0: To optional.
logger (Optional[
Logger.Logger]) –Logger object.
New in version 1.4.0.
loop (Optional[
asyncio.AbstractEventLoop]) – Theasyncio.AbstractEventLoopto use for asynchronous operations. Defaults toNone, in which case the default event loop is used viaasyncio.get_event_loop().debug (
bool) –Print announce in client object.
New in version 1.4.5.
- @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.
- property channel_manager: _ChannelManager¶
- Channels manager.
versionadded:: 1.4.5
- Return type:
_ChannelManager
- 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.
- property team_manager: _TeamManager¶
- Teams manager.
versionadded:: 1.4.5
- Return type:
_TeamManager