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: Client

The bot instance that this gateway client belongs to.

intents: Intents | None

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

cache_flags: GatewayCacheFlags | None

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

automatic_shards: bool

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

shard_id: int | None

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

shard_count: int

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

shard_ids: list[int] | None

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

max_concurrency: int | None

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

async request_soundboard_sounds(*guild_ids) → None

Requests the soundboard sounds of the guilds, through the shard each guild belongs to.

The sounds are dispatched in soundboard_sounds events, one per guild.

Parameters:

guild_ids (Snowflake | int) – The guild IDs to request the soundboard sounds for

Return type:

None

async request_channel_info(guild_id, *, fields=None) → None

Requests the ephemeral channel data of a guild, through the shard the guild belongs to.

The data is dispatched in a channel_info event.

Parameters:
  • guild_id (Snowflake | int) – The guild ID to request the channel info for

  • fields (list[Literal['status', 'voice_start_time']] | None) – The fields to request, defaults to both status and voice_start_time

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