Files
simplex-chat/packages/simplex-chat-nodejs/docs/api.Class.ChatApi.md
Evgeny 43aa3e7e8a nodejs: simplex-chat npm package (#5556)
* nodejs: addon

* rename

* changes

* change lib name

* package

* lib path

* simplex-chat-nodejs: fix library paths

* simplex-chat-nodejs: change addon name

* simplex-chat-nodejs: install libs, adjust package and installation

* simplex-chat-nodejs: add npmignore

* gitignore: add additional nodejs path

* simplex-chat-nodejs: fix shim name

* gitignore: ignore nodejs package lock

* simplex-chat-nodejs: rename shim to underscore

* simplex-chat-nodejs: fix library loading on Mac

* simplex-chat-nodejs: expose low-level functions, move tests

* simplex-chat-nodejs: expose shim fucntions

* simplex-chat-nodejs: fixed libs version

* simplex-chat-nodejs: switch to official repository

* simpelx-chat-nodejs: adjust release tag

* async addon, tests

* refactor, fixes

* high level chat api

* simplify cpp add-on - move logic to JS, fix API

* api for events, api test

* update @simplex-chat/types

* Revert "update @simplex-chat/types"

This reverts commit da3f89866f.

* change @simplex-chat/types version

* receiver for any events, wait with timeout

* low-level bot example

* typedoc

* network connection events

* declarative bot api

* readme, docs

* update docs

* update readme

* add liveMessage support

* allow passing welcome message as string

* @simplex-chat/webrtc-client 6.5.0-beta.3

* bot test

* concurrent connection in tests

* nodejs/download-libs: cleanup on version mismatch

* nodejs/download-libs: bump libs version

* do not handle signals in Haskell

* update bot examples

* flatten docs and use local links to code

* update readme

* 6.5.0-beta.4

* include more files in npm package, 6.5.0-beta.4.2

* .gitignore

---------

Co-authored-by: Avently <7953703+avently@users.noreply.github.com>
Co-authored-by: shum <github.shum@liber.li>
2026-01-14 21:42:21 +00:00

1603 lines
22 KiB
Markdown

[**simplex-chat**](README.md)
***
[simplex-chat](README.md) / [api](Namespace.api.md) / ChatApi
# Class: ChatApi
Defined in: [src/api.ts:62](../src/api.ts#L62)
Main API class for interacting with the chat core library.
## Properties
### ctrl\_
> `protected` **ctrl\_**: `bigint` \| `undefined`
Defined in: [src/api.ts:68](../src/api.ts#L68)
## Accessors
### ctrl
#### Get Signature
> **get** **ctrl**(): `bigint`
Defined in: [src/api.ts:295](../src/api.ts#L295)
Chat controller reference
##### Returns
`bigint`
***
### initialized
#### Get Signature
> **get** **initialized**(): `boolean`
Defined in: [src/api.ts:281](../src/api.ts#L281)
Chat controller is initialized
##### Returns
`boolean`
***
### started
#### Get Signature
> **get** **started**(): `boolean`
Defined in: [src/api.ts:288](../src/api.ts#L288)
Chat controller is started
##### Returns
`boolean`
## Methods
### apiAcceptContactRequest()
> **apiAcceptContactRequest**(`contactReqId`): `Promise`\<`Contact`\>
Defined in: [src/api.ts:697](../src/api.ts#L697)
Accept contact request.
Network usage: interactive.
#### Parameters
##### contactReqId
`number`
#### Returns
`Promise`\<`Contact`\>
***
### apiAcceptMember()
> **apiAcceptMember**(`groupId`, `groupMemberId`, `memberRole`): `Promise`\<`GroupMember`\>
Defined in: [src/api.ts:517](../src/api.ts#L517)
Accept group member. Requires Admin role.
Network usage: background.
#### Parameters
##### groupId
`number`
##### groupMemberId
`number`
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`GroupMember`\>
***
### apiAddMember()
> **apiAddMember**(`groupId`, `contactId`, `memberRole`): `Promise`\<`GroupMember`\>
Defined in: [src/api.ts:497](../src/api.ts#L497)
Add contact to group. Requires bot to have Admin role.
Network usage: interactive.
#### Parameters
##### groupId
`number`
##### contactId
`number`
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`GroupMember`\>
***
### apiBlockMembersForAll()
> **apiBlockMembersForAll**(`groupId`, `groupMemberIds`, `blocked`): `Promise`\<`void`\>
Defined in: [src/api.ts:537](../src/api.ts#L537)
Block members. Requires Moderator role.
Network usage: background.
#### Parameters
##### groupId
`number`
##### groupMemberIds
`number`[]
##### blocked
`boolean`
#### Returns
`Promise`\<`void`\>
***
### apiCancelFile()
> **apiCancelFile**(`fileId`): `Promise`\<`void`\>
Defined in: [src/api.ts:487](../src/api.ts#L487)
Cancel file.
Network usage: background.
#### Parameters
##### fileId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiChatItemReaction()
> **apiChatItemReaction**(`chatType`, `chatId`, `chatItemId`, `add`, `reaction`): `Promise`\<`ChatItemDeletion`[]\>
Defined in: [src/api.ts:461](../src/api.ts#L461)
Add/remove message reaction.
Network usage: background.
#### Parameters
##### chatType
`ChatType`
##### chatId
`number`
##### chatItemId
`number`
##### add
`boolean`
##### reaction
`MsgReaction`
#### Returns
`Promise`\<`ChatItemDeletion`[]\>
***
### apiConnect()
> **apiConnect**(`userId`, `incognito`, `preparedLink?`): `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
Defined in: [src/api.ts:666](../src/api.ts#L666)
Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link
Network usage: interactive.
#### Parameters
##### userId
`number`
##### incognito
`boolean`
##### preparedLink?
`CreatedConnLink`
#### Returns
`Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
***
### apiConnectActiveUser()
> **apiConnectActiveUser**(`connLink`): `Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
Defined in: [src/api.ts:675](../src/api.ts#L675)
Connect via SimpleX link as string in the active user profile.
Network usage: interactive.
#### Parameters
##### connLink
`string`
#### Returns
`Promise`\<[`ConnReqType`](api.Enumeration.ConnReqType.md)\>
***
### apiConnectPlan()
> **apiConnectPlan**(`userId`, `connectionLink`): `Promise`\<\[`ConnectionPlan`, `CreatedConnLink`\]\>
Defined in: [src/api.ts:656](../src/api.ts#L656)
Determine SimpleX link type and if the bot is already connected via this link.
Network usage: interactive.
#### Parameters
##### userId
`number`
##### connectionLink
`string`
#### Returns
`Promise`\<\[`ConnectionPlan`, `CreatedConnLink`\]\>
***
### apiCreateActiveUser()
> **apiCreateActiveUser**(`profile?`): `Promise`\<`User`\>
Defined in: [src/api.ts:774](../src/api.ts#L774)
Create new user profile
Network usage: no.
#### Parameters
##### profile?
`Profile`
#### Returns
`Promise`\<`User`\>
***
### apiCreateGroupLink()
> **apiCreateGroupLink**(`groupId`, `memberRole`): `Promise`\<`string`\>
Defined in: [src/api.ts:597](../src/api.ts#L597)
Create group link.
Network usage: interactive.
#### Parameters
##### groupId
`number`
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`string`\>
***
### apiCreateLink()
> **apiCreateLink**(`userId`): `Promise`\<`string`\>
Defined in: [src/api.ts:643](../src/api.ts#L643)
Create 1-time invitation link.
Network usage: interactive.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`string`\>
***
### apiCreateUserAddress()
> **apiCreateUserAddress**(`userId`): `Promise`\<`CreatedConnLink`\>
Defined in: [src/api.ts:312](../src/api.ts#L312)
Create bot address.
Network usage: interactive.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`CreatedConnLink`\>
***
### apiDeleteChat()
> **apiDeleteChat**(`chatType`, `chatId`, `deleteMode`): `Promise`\<`void`\>
Defined in: [src/api.ts:737](../src/api.ts#L737)
Delete chat.
Network usage: background.
#### Parameters
##### chatType
`ChatType`
##### chatId
`number`
##### deleteMode
`ChatDeleteMode` = `...`
#### Returns
`Promise`\<`void`\>
***
### apiDeleteChatItems()
> **apiDeleteChatItems**(`chatType`, `chatId`, `chatItemIds`, `deleteMode`): `Promise`\<`ChatItemDeletion`[]\>
Defined in: [src/api.ts:436](../src/api.ts#L436)
Delete message.
Network usage: background.
#### Parameters
##### chatType
`ChatType`
##### chatId
`number`
##### chatItemIds
`number`[]
##### deleteMode
`CIDeleteMode`
#### Returns
`Promise`\<`ChatItemDeletion`[]\>
***
### apiDeleteGroupLink()
> **apiDeleteGroupLink**(`groupId`): `Promise`\<`void`\>
Defined in: [src/api.ts:619](../src/api.ts#L619)
Delete group link.
Network usage: background.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiDeleteMemberChatItem()
> **apiDeleteMemberChatItem**(`groupId`, `chatItemIds`): `Promise`\<`ChatItemDeletion`[]\>
Defined in: [src/api.ts:451](../src/api.ts#L451)
Moderate message. Requires Moderator role (and higher than message author's).
Network usage: background.
#### Parameters
##### groupId
`number`
##### chatItemIds
`number`[]
#### Returns
`Promise`\<`ChatItemDeletion`[]\>
***
### apiDeleteUser()
> **apiDeleteUser**(`userId`, `delSMPQueues`, `viewPwd?`): `Promise`\<`void`\>
Defined in: [src/api.ts:804](../src/api.ts#L804)
Delete user profile.
Network usage: background.
#### Parameters
##### userId
`number`
##### delSMPQueues
`boolean`
##### viewPwd?
`string`
#### Returns
`Promise`\<`void`\>
***
### apiDeleteUserAddress()
> **apiDeleteUserAddress**(`userId`): `Promise`\<`void`\>
Defined in: [src/api.ts:322](../src/api.ts#L322)
Deletes a user address.
Network usage: background.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiGetActiveUser()
> **apiGetActiveUser**(): `Promise`\<`User` \| `undefined`\>
Defined in: [src/api.ts:754](../src/api.ts#L754)
Get active user profile
Network usage: no.
#### Returns
`Promise`\<`User` \| `undefined`\>
***
### apiGetGroupLink()
> **apiGetGroupLink**(`groupId`): `Promise`\<`GroupLink`\>
Defined in: [src/api.ts:628](../src/api.ts#L628)
Get group link.
Network usage: no.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupLink`\>
***
### apiGetGroupLinkStr()
> **apiGetGroupLinkStr**(`groupId`): `Promise`\<`string`\>
Defined in: [src/api.ts:634](../src/api.ts#L634)
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`string`\>
***
### apiGetUserAddress()
> **apiGetUserAddress**(`userId`): `Promise`\<`UserContactLink` \| `undefined`\>
Defined in: [src/api.ts:332](../src/api.ts#L332)
Get bot address and settings.
Network usage: no.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`UserContactLink` \| `undefined`\>
***
### apiJoinGroup()
> **apiJoinGroup**(`groupId`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:507](../src/api.ts#L507)
Join group.
Network usage: interactive.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiLeaveGroup()
> **apiLeaveGroup**(`groupId`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:557](../src/api.ts#L557)
Leave group.
Network usage: background.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiListContacts()
> **apiListContacts**(`userId`): `Promise`\<`Contact`[]\>
Defined in: [src/api.ts:717](../src/api.ts#L717)
Get contacts.
Network usage: no.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`Contact`[]\>
***
### apiListGroups()
> **apiListGroups**(`userId`, `contactId?`, `search?`): `Promise`\<`GroupInfo`[]\>
Defined in: [src/api.ts:727](../src/api.ts#L727)
Get groups.
Network usage: no.
#### Parameters
##### userId
`number`
##### contactId?
`number`
##### search?
`string`
#### Returns
`Promise`\<`GroupInfo`[]\>
***
### apiListMembers()
> **apiListMembers**(`groupId`): `Promise`\<`GroupMember`[]\>
Defined in: [src/api.ts:567](../src/api.ts#L567)
Get group members.
Network usage: no.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupMember`[]\>
***
### apiListUsers()
> **apiListUsers**(): `Promise`\<`UserInfo`[]\>
Defined in: [src/api.ts:784](../src/api.ts#L784)
Get all user profiles
Network usage: no.
#### Returns
`Promise`\<`UserInfo`[]\>
***
### apiNewGroup()
> **apiNewGroup**(`userId`, `groupProfile`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:577](../src/api.ts#L577)
Create group.
Network usage: no.
#### Parameters
##### userId
`number`
##### groupProfile
`GroupProfile`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiReceiveFile()
> **apiReceiveFile**(`fileId`): `Promise`\<`AChatItem`\>
Defined in: [src/api.ts:477](../src/api.ts#L477)
Receive file.
Network usage: no.
#### Parameters
##### fileId
`number`
#### Returns
`Promise`\<`AChatItem`\>
***
### apiRejectContactRequest()
> **apiRejectContactRequest**(`contactReqId`): `Promise`\<`void`\>
Defined in: [src/api.ts:707](../src/api.ts#L707)
Reject contact request. The user who sent the request is **not notified**.
Network usage: no.
#### Parameters
##### contactReqId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiRemoveMembers()
> **apiRemoveMembers**(`groupId`, `memberIds`, `withMessages`): `Promise`\<`GroupMember`[]\>
Defined in: [src/api.ts:547](../src/api.ts#L547)
Remove members. Requires Admin role.
Network usage: background.
#### Parameters
##### groupId
`number`
##### memberIds
`number`[]
##### withMessages
`boolean` = `false`
#### Returns
`Promise`\<`GroupMember`[]\>
***
### apiSendMessages()
> **apiSendMessages**(`chat`, `messages`, `liveMessage`): `Promise`\<`AChatItem`[]\>
Defined in: [src/api.ts:381](../src/api.ts#L381)
Send messages.
Network usage: background.
#### Parameters
##### chat
`ChatInfo` | `ChatRef` | \[`ChatType`, `number`\]
##### messages
`ComposedMessage`[]
##### liveMessage
`boolean` = `false`
#### Returns
`Promise`\<`AChatItem`[]\>
***
### apiSendTextMessage()
> **apiSendTextMessage**(`chat`, `text`, `inReplyTo?`): `Promise`\<`AChatItem`[]\>
Defined in: [src/api.ts:403](../src/api.ts#L403)
Send text message.
Network usage: background.
#### Parameters
##### chat
`ChatInfo` | `ChatRef` | \[`ChatType`, `number`\]
##### text
`string`
##### inReplyTo?
`number`
#### Returns
`Promise`\<`AChatItem`[]\>
***
### apiSendTextReply()
> **apiSendTextReply**(`chatItem`, `text`): `Promise`\<`AChatItem`[]\>
Defined in: [src/api.ts:411](../src/api.ts#L411)
Send text message in reply to received message.
Network usage: background.
#### Parameters
##### chatItem
`AChatItem`
##### text
`string`
#### Returns
`Promise`\<`AChatItem`[]\>
***
### apiSetActiveUser()
> **apiSetActiveUser**(`userId`, `viewPwd?`): `Promise`\<`User`\>
Defined in: [src/api.ts:794](../src/api.ts#L794)
Set active user profile
Network usage: no.
#### Parameters
##### userId
`number`
##### viewPwd?
`string`
#### Returns
`Promise`\<`User`\>
***
### apiSetAddressSettings()
> **apiSetAddressSettings**(`userId`, `__namedParameters`): `Promise`\<`void`\>
Defined in: [src/api.ts:364](../src/api.ts#L364)
Set bot address settings.
Network usage: interactive.
#### Parameters
##### userId
`number`
##### \_\_namedParameters
[`BotAddressSettings`](api.Interface.BotAddressSettings.md)
#### Returns
`Promise`\<`void`\>
***
### apiSetContactPrefs()
> **apiSetContactPrefs**(`contactId`, `preferences`): `Promise`\<`void`\>
Defined in: [src/api.ts:830](../src/api.ts#L830)
Configure chat preference overrides for the contact.
Network usage: background.
#### Parameters
##### contactId
`number`
##### preferences
`Preferences`
#### Returns
`Promise`\<`void`\>
***
### apiSetGroupLinkMemberRole()
> **apiSetGroupLinkMemberRole**(`groupId`, `memberRole`): `Promise`\<`void`\>
Defined in: [src/api.ts:610](../src/api.ts#L610)
Set member role for group link.
Network usage: no.
#### Parameters
##### groupId
`number`
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`void`\>
***
### apiSetMembersRole()
> **apiSetMembersRole**(`groupId`, `groupMemberIds`, `memberRole`): `Promise`\<`void`\>
Defined in: [src/api.ts:527](../src/api.ts#L527)
Set members role. Requires Admin role.
Network usage: background.
#### Parameters
##### groupId
`number`
##### groupMemberIds
`number`[]
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`void`\>
***
### apiSetProfileAddress()
> **apiSetProfileAddress**(`userId`, `enable`): `Promise`\<`UserProfileUpdateSummary`\>
Defined in: [src/api.ts:350](../src/api.ts#L350)
Add address to bot profile.
Network usage: interactive.
#### Parameters
##### userId
`number`
##### enable
`boolean`
#### Returns
`Promise`\<`UserProfileUpdateSummary`\>
***
### apiUpdateChatItem()
> **apiUpdateChatItem**(`chatType`, `chatId`, `chatItemId`, `msgContent`, `liveMessage`): `Promise`\<`ChatItem`\>
Defined in: [src/api.ts:419](../src/api.ts#L419)
Update message.
Network usage: background.
#### Parameters
##### chatType
`ChatType`
##### chatId
`number`
##### chatItemId
`number`
##### msgContent
`MsgContent`
##### liveMessage
`false`
#### Returns
`Promise`\<`ChatItem`\>
***
### apiUpdateGroupProfile()
> **apiUpdateGroupProfile**(`groupId`, `groupProfile`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:587](../src/api.ts#L587)
Update group profile.
Network usage: background.
#### Parameters
##### groupId
`number`
##### groupProfile
`GroupProfile`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiUpdateProfile()
> **apiUpdateProfile**(`userId`, `profile`): `Promise`\<`UserProfileUpdateSummary` \| `undefined`\>
Defined in: [src/api.ts:814](../src/api.ts#L814)
Update user profile.
Network usage: background.
#### Parameters
##### userId
`number`
##### profile
`Profile`
#### Returns
`Promise`\<`UserProfileUpdateSummary` \| `undefined`\>
***
### close()
> **close**(): `Promise`\<`void`\>
Defined in: [src/api.ts:114](../src/api.ts#L114)
Close chat database.
Usually doesn't need to be called in chat bots.
#### Returns
`Promise`\<`void`\>
***
### off()
> **off**\<`K`\>(`event`, `subscriber`): `void`
Defined in: [src/api.ts:253](../src/api.ts#L253)
Unsubscribe all or a specific handler from a specific event.
#### Type Parameters
##### K
`K` *extends* `Tag`
#### Parameters
##### event
`K`
The event type to unsubscribe from.
##### subscriber
An optional subscriber function for the event.
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\> | `undefined`
#### Returns
`void`
***
### offAny()
> **offAny**(`receiver`): `void`
Defined in: [src/api.ts:269](../src/api.ts#L269)
Unsubscribe all or a specific handler from any events.
#### Parameters
##### receiver
An optional subscriber function for the event.
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`Tag`\> | `undefined`
#### Returns
`void`
***
### on()
#### Call Signature
> **on**\<`K`\>(`subscribers`): `void`
Defined in: [src/api.ts:163](../src/api.ts#L163)
Subscribe multiple event handlers at once.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### subscribers
[`EventSubscribers`](api.TypeAlias.EventSubscribers.md)
An object mapping event types (CEvt.Tag) to their subscriber functions.
##### Returns
`void`
##### Throws
If the same function is subscribed to event.
#### Call Signature
> **on**\<`K`\>(`event`, `subscriber`): `void`
Defined in: [src/api.ts:171](../src/api.ts#L171)
Subscribe a handler to a specific event.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### event
`K`
The event type to subscribe to.
###### subscriber
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\>
The subscriber function for the event.
##### Returns
`void`
##### Throws
If the same function is subscribed to event.
***
### onAny()
> **onAny**(`receiver`): `void`
Defined in: [src/api.ts:194](../src/api.ts#L194)
Subscribe a handler to any event.
#### Parameters
##### receiver
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`Tag`\>
The receiver function for any event.
#### Returns
`void`
#### Throws
If the same function is subscribed to event.
***
### once()
> **once**\<`K`\>(`event`, `subscriber`): `void`
Defined in: [src/api.ts:205](../src/api.ts#L205)
Subscribe a handler to a specific event to be delivered one time.
#### Type Parameters
##### K
`K` *extends* `Tag`
#### Parameters
##### event
`K`
The event type to subscribe to.
##### subscriber
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\>
The subscriber function for the event.
#### Returns
`void`
#### Throws
If the same function is subscribed to event.
***
### recvChatEvent()
> **recvChatEvent**(`wait`): `Promise`\<`ChatEvent` \| `undefined`\>
Defined in: [src/api.ts:304](../src/api.ts#L304)
#### Parameters
##### wait
`number` = `5_000_000`
#### Returns
`Promise`\<`ChatEvent` \| `undefined`\>
***
### sendChatCmd()
> **sendChatCmd**(`cmd`): `Promise`\<`ChatResponse`\>
Defined in: [src/api.ts:300](../src/api.ts#L300)
#### Parameters
##### cmd
`string`
#### Returns
`Promise`\<`ChatResponse`\>
***
### startChat()
> **startChat**(): `Promise`\<`void`\>
Defined in: [src/api.ts:88](../src/api.ts#L88)
Start chat controller. Must be called with the existing user profile.
#### Returns
`Promise`\<`void`\>
***
### stopChat()
> **stopChat**(): `Promise`\<`void`\>
Defined in: [src/api.ts:102](../src/api.ts#L102)
Stop chat controller.
Must be called before closing the database.
Usually doesn't need to be called in chat bots.
#### Returns
`Promise`\<`void`\>
***
### wait()
#### Call Signature
> **wait**\<`K`\>(`event`): `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
Defined in: [src/api.ts:213](../src/api.ts#L213)
Waits for specific event, with an optional predicate.
Returns `undefined` on timeout if specified.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### event
`K`
##### Returns
`Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
#### Call Signature
> **wait**\<`K`\>(`event`, `predicate`): `Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
Defined in: [src/api.ts:214](../src/api.ts#L214)
Waits for specific event, with an optional predicate.
Returns `undefined` on timeout if specified.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### event
`K`
###### predicate
(`event`) => `boolean` | `undefined`
##### Returns
`Promise`\<`ChatEvent` & \{ `type`: `K`; \}\>
#### Call Signature
> **wait**\<`K`\>(`event`, `timeout`): `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
Defined in: [src/api.ts:215](../src/api.ts#L215)
Waits for specific event, with an optional predicate.
Returns `undefined` on timeout if specified.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### event
`K`
###### timeout
`number`
##### Returns
`Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
#### Call Signature
> **wait**\<`K`\>(`event`, `predicate`, `timeout`): `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
Defined in: [src/api.ts:216](../src/api.ts#L216)
Waits for specific event, with an optional predicate.
Returns `undefined` on timeout if specified.
##### Type Parameters
###### K
`K` *extends* `Tag`
##### Parameters
###### event
`K`
###### predicate
(`event`) => `boolean` | `undefined`
###### timeout
`number`
##### Returns
`Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
***
### init()
> `static` **init**(`dbFilePrefix`, `dbKey?`, `confirm?`): `Promise`\<`ChatApi`\>
Defined in: [src/api.ts:76](../src/api.ts#L76)
Initializes the ChatApi.
#### Parameters
##### dbFilePrefix
`string`
File prefix for the database files.
##### dbKey?
`string` = `""`
Database encryption key.
##### confirm?
[`MigrationConfirmation`](core.Enumeration.MigrationConfirmation.md) = `core.MigrationConfirmation.YesUp`
Migration confirmation mode.
#### Returns
`Promise`\<`ChatApi`\>