Skip to content

Base Client

Base Client

Internal API

These classes are for internal use only.

Users should interact with Client and other public API classes instead.


BaseClient

Bases: Protocol

Exposes a common interface for Client.

token: str instance-attribute

Bot's token.

application_id: int instance-attribute

Bot's application ID.

intents: int instance-attribute

Bot intents for listening to events.

shards: list[GatewayClient] instance-attribute

Shards as a list of gateways.

logger: LoggerLike instance-attribute

Logger instance to log events.

events: dict[str:(list[callable])] instance-attribute

Events for the client to listen to.

startup_hooks: list[callable] instance-attribute

Handlers to call once before the bot starts.

shutdown_hooks: list[callable] instance-attribute

Handlers to call once after the bot shuts down.

add_event_listener(event: str, handler)

Helper function to register listener functions.

Parameters:

  • event (str) –

    name of the event to listen

  • handler (callable) –

    listener function

add_startup_hook(handler)

Helper function to register startup functions. Runs once on startup BEFORE READY event.

Parameters:

  • handler (callable) –

    startup function

add_shutdown_hook(handler)

Helper function to register shutdown functions. Runs once on shutdown.

Parameters:

  • handler (callable) –

    shutdown function

application(application_id: int)

Creates an interactable application resource.

Parameters:

  • application_id (int) –

    ID of target application

Returns:

bot_emoji()

Creates an interactable bot emoji resource.

Returns:

  • BotEmojis

    the BotEmoji resource

guild_emoji(guild_id: int)

Creates an interactable emoji resource.

Parameters:

  • guild_id (int) –

    guild ID of target emojis

Returns:

guild(guild_id: int, *, context=None)

Creates an interactable guild resource.

Parameters:

  • guild_id (int) –

    ID of target guild

  • context (Any, default: None ) –

    optional associated data

Returns:

  • Guild

    the Guild resource

channel(channel_id: int, *, context=None)

Creates an interactable channel resource.

Parameters:

  • channel_id (int) –

    ID of target channel

  • context (Any, default: None ) –

    optional associated data

Returns:

message(channel_id: int, message_id: int, *, context=None)

Creates an interactable message resource.

Parameters:

  • message_id (int) –

    ID of target message

  • channel_id (int) –

    channel ID of target message

  • context (Any, default: None ) –

    optional associated data

Returns:

interaction(id: int, token: str, *, context=None)

Creates an interactable interaction resource.

Parameters:

  • id (int) –

    ID of the interaction

  • token (str) –

    interaction token

  • context (Any, default: None ) –

    optional associated data

Returns:

user(user_id: int, *, context=None)

Creates an interactable user resource.

Parameters:

  • user_id (int) –

    ID of target user

  • context (Any, default: None ) –

    optional associated data

Returns:

  • User

    the User resource

register_guild_commands(commands: list[SlashCommand | UserCommand | MessageCommand], guild_id: int) async

Registers commands at the guild level.

Parameters:

register_global_commands(commands: list[SlashCommand | UserCommand | MessageCommand]) async

Registers a command at the global/bot level. (ALL GUILDS)

Parameters:

start() async

Starts the HTTP/Websocket client, run startup logic, and registers commands.