API Reference

speedcord.__version__

A string representation of the version. e.g. '0.1.2'.

class speedcord.Client(intents, token=None, *, shard_count=None, shard_ids=None)
run()

Starts the client.

await get_gateway()

Get details about the gateway

Returns

A tuple consisting of the wss url to connect to, how many shards to use, how many gateway connections left, how many milliseconds until the gateway connection limit resets.

Return type

Tuple[str, int, int, int]

Raises

Unauthorized – Authentication failed.

await connect()

Connects to discord and spawns shards. start() has to be called first!

Raises

InvalidToken – Provided token is invalid.

await start()

Sets up the HTTP client, connects to Discord, and spawns shards.

Raises

InvalidToken – Provided token is invalid.

await close()

Closes the HTTP client and disconnects all shards.

await fatal(exception)

Raises a fatal exception to the bot. Please do not use this for non-fatal exceptions.

listen(event)

Listen to an event or opcode.

Parameters

event (Union[int, str]) – An opcode or event name to listen to.

Raises

TypeError – Invalid event type was passed.

await handle_dispatch(data, shard)

Dispatches a event to the event handler.

Parameters
  • data (Dict[str, Any]) – The data to dispatch.

  • shard (DefaultShard) – Shard the event was received on.

Exceptions

exception speedcord.HTTPException(request, data)

Exception that’s thrown when an HTTP request operation fails.

exception speedcord.Forbidden(request, data)

Exception that’s thrown for when status code 403 occurs.

Subclass of HTTPException

exception speedcord.NotFound(request)

Exception that’s thrown when status code 404 occurs.

Subclass of HTTPException

exception speedcord.Unauthorized(request)

Exception that’s thrown when status code 401 occurs.

Subclass of HTTPException

exception speedcord.LoginException

Base exception thrown when an issue occurs during login attempts.

exception speedcord.InvalidToken

Exception that’s thrown when an attempt to login with invalid token is made.

exception speedcord.ConnectionsExceeded

Exception that’s thrown when all gateway IDENTIFYs are exhausted.

exception speedcord.GatewayException

Base exception that’s thrown whenever a gateway error occurs.

exception speedcord.GatewayClosed

Exception that’s thrown when the gateway is used while in a closed state.

exception speedcord.GatewayUnavailable

Exception that’s thrown when the gateway is unreachable.