telegramx.js

Client

class

extends TypedEmitter<ClientEvents>

The main entry point of the library. Wraps the transport, emits typed events for incoming updates, and exposes the full Bot API via .

Declaration

declare class Client extends TypedEmitter<ClientEvents> 

Properties

apiproperty#
readonly api: ApiMethods;

Fully-typed access to every Bot API method.

isReadyproperty#
get isReady(): boolean;

Whether the client has completed login.

pollingproperty#
readonly polling: PollingClient;
readyAtproperty#
readyAt: Date | null;

When the client became ready.

restproperty#
readonly rest: REST;
tokenproperty#
get token(): string | null;
uptimeproperty#
get uptime(): number | null;

Milliseconds since the client became ready, or null if not ready.

userproperty#
user: ClientUser | null;

The bot's own account. null until resolves.

webhookproperty#
readonly webhook: WebhookClient;

Methods

(constructor)constructor#
constructor(options?: ClientOptions);

Constructs a new instance of the Client class

loginmethod#
login(token?: string | null): Promise<ClientUser>;
ParameterType
token?string | null
Returns Promise<ClientUser>

Authenticate the bot, fetch its own account via getMe, and emit ready. Does not start receiving updates — call or set up a webhook for that.

startPolling(options?: PollingOptions): Promise<ClientUser>;
ParameterType
options?PollingOptions
Returns Promise<ClientUser>

Log in and immediately start long polling for updates.

stopPolling(): void;
Returns void

Stop long polling, if running.