Client

Note

Keep in mind that this is not generally used by you, but rather by discord.http only.

discord_http.gateway.client module

class discord_http.gateway.client.GatewayClient(bot, *, cache_flags=None, intents=None, automatic_shards=True, shard_id=None, shard_count=1, shard_ids=None, max_concurrency=None)

Bases: object

Represents the discord.http/gateway client of the bot.

Parameters:
bot

The bot instance that this gateway client belongs to.

intents

The intents that the gateway client is using, or None if not specified.

cache_flags

The cache flags that the gateway client is using, or None if not specified.

automatic_shards

Whether to automatically determine the number of shards to launch based on the gateway response.

shard_id

The shard ID to launch, or None if not specified.

shard_count

The total number of shards to launch, defaults to 1.

shard_ids

A list of shard IDs to launch, or None to launch all shards from 0 to shard_count - 1.

max_concurrency

The maximum number of shards to launch concurrently, or None to launch all shards at once.

get_shard(shard_id) Shard | None

Returns the shard object of the shard with the specified ID.

Parameters:

shard_id (int) – The ID of the shard to get.

Return type:

Shard | None

Returns:

The shard object with the specified ID, or None if not found.

async change_presence(status) None

Changes the presence of all shards to the specified status.

Parameters:

status (PlayingStatus) – The status to change to.

Return type:

None

shard_by_guild_id(guild_id) int

Returns the shard ID of the shard that the guild is in.

Parameters:

guild_id (Snowflake | int) – The ID of the guild to get the shard ID of

Return type:

int

Returns:

The shard ID of the guild

start() None

Start the gateway client.

Return type:

None

async close() None

Close the gateway client.

Return type:

None