Client Object

Clients

Methods
class slack.Client(user_token: str, bot_token: str, token: str, 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.

user_token

The connector to use for connection pooling.

Type

str

bot_token

Proxy URL.

Type

str

token

Integer starting at 0 and less than shard_count.

Type

str

loop

The asyncio.AbstractEventLoop to use for asynchronous operations. Defaults to None, in which case the default event loop is used via asyncio.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.

await connect(ws_url: str) None

connect to slack-API :param ws_url: :type ws_url: str

dispatch(event: str, *args, **kwargs) None

Dispatch event with any keyword. :param event: The event name. :type event: str :param args: params of event action. :type args: Any :param kwargs: keyword of event action. :type kwargs: Any

is_closed() bool

It returns a boolean value.

Return type

The return value is a boolean value.

await login() None

login as bot

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 or connect() + 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.

await start() None

start connection.