Files
simplex-chat/packages/simplex-chat-nodejs/docs/api.Class.ChatApi.md
T
sh 42dd36bf09 simplex-chat-nodejs: typed DbConfig (#6875)
* simplex-chat-nodejs: typed DbConfig for ChatApi.init and BotDbOpts

* simplex-chat-nodejs: regenerate typedoc docs for DbConfig

* simplex-chat-nodejs: rename DbConfig.kind to .type
2026-04-24 16:43:43 +01:00

1753 lines
24 KiB
Markdown

[**simplex-chat**](README.md)
***
[simplex-chat](README.md) / [api](Namespace.api.md) / ChatApi
# Class: ChatApi
Defined in: [src/api.ts:97](../src/api.ts#L97)
Main API class for interacting with the chat core library.
## Properties
### ctrl\_
> `protected` **ctrl\_**: `bigint` \| `undefined`
Defined in: [src/api.ts:103](../src/api.ts#L103)
## Accessors
### ctrl
#### Get Signature
> **get** **ctrl**(): `bigint`
Defined in: [src/api.ts:329](../src/api.ts#L329)
Chat controller reference
##### Returns
`bigint`
***
### initialized
#### Get Signature
> **get** **initialized**(): `boolean`
Defined in: [src/api.ts:315](../src/api.ts#L315)
Chat controller is initialized
##### Returns
`boolean`
***
### started
#### Get Signature
> **get** **started**(): `boolean`
Defined in: [src/api.ts:322](../src/api.ts#L322)
Chat controller is started
##### Returns
`boolean`
## Methods
### apiAcceptContactRequest()
> **apiAcceptContactRequest**(`contactReqId`): `Promise`\<`Contact`\>
Defined in: [src/api.ts:731](../src/api.ts#L731)
Accept contact request.
Network usage: interactive.
#### Parameters
##### contactReqId
`number`
#### Returns
`Promise`\<`Contact`\>
***
### apiAcceptMember()
> **apiAcceptMember**(`groupId`, `groupMemberId`, `memberRole`): `Promise`\<`GroupMember`\>
Defined in: [src/api.ts:551](../src/api.ts#L551)
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:531](../src/api.ts#L531)
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:571](../src/api.ts#L571)
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:521](../src/api.ts#L521)
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:495](../src/api.ts#L495)
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:700](../src/api.ts#L700)
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:709](../src/api.ts#L709)
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:690](../src/api.ts#L690)
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:849](../src/api.ts#L849)
Create new user profile
Network usage: no.
#### Parameters
##### profile?
`Profile`
#### Returns
`Promise`\<`User`\>
***
### apiCreateGroupLink()
> **apiCreateGroupLink**(`groupId`, `memberRole`): `Promise`\<`string`\>
Defined in: [src/api.ts:631](../src/api.ts#L631)
Create group link.
Network usage: interactive.
#### Parameters
##### groupId
`number`
##### memberRole
`GroupMemberRole`
#### Returns
`Promise`\<`string`\>
***
### apiCreateLink()
> **apiCreateLink**(`userId`): `Promise`\<`string`\>
Defined in: [src/api.ts:677](../src/api.ts#L677)
Create 1-time invitation link.
Network usage: interactive.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`string`\>
***
### apiCreateMemberContact()
> **apiCreateMemberContact**(`groupId`, `groupMemberId`): `Promise`\<`Contact`\>
Defined in: [src/api.ts:915](../src/api.ts#L915)
Create a direct message contact with a group member.
Returns the created contact.
Network usage: interactive.
#### Parameters
##### groupId
`number`
##### groupMemberId
`number`
#### Returns
`Promise`\<`Contact`\>
***
### apiCreateUserAddress()
> **apiCreateUserAddress**(`userId`): `Promise`\<`CreatedConnLink`\>
Defined in: [src/api.ts:346](../src/api.ts#L346)
Create bot address.
Network usage: interactive.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`CreatedConnLink`\>
***
### apiDeleteChat()
> **apiDeleteChat**(`chatType`, `chatId`, `deleteMode?`): `Promise`\<`void`\>
Defined in: [src/api.ts:771](../src/api.ts#L771)
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:470](../src/api.ts#L470)
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:653](../src/api.ts#L653)
Delete group link.
Network usage: background.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiDeleteMemberChatItem()
> **apiDeleteMemberChatItem**(`groupId`, `chatItemIds`): `Promise`\<`ChatItemDeletion`[]\>
Defined in: [src/api.ts:485](../src/api.ts#L485)
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:879](../src/api.ts#L879)
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:356](../src/api.ts#L356)
Deletes a user address.
Network usage: background.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`void`\>
***
### apiGetActiveUser()
> **apiGetActiveUser**(): `Promise`\<`User` \| `undefined`\>
Defined in: [src/api.ts:829](../src/api.ts#L829)
Get active user profile
Network usage: no.
#### Returns
`Promise`\<`User` \| `undefined`\>
***
### apiGetChat()
> **apiGetChat**(`chatType`, `chatId`, `count`): `Promise`\<`any`\>
Defined in: [src/api.ts:819](../src/api.ts#L819)
Get chat items.
Network usage: no.
#### Parameters
##### chatType
`ChatType`
##### chatId
`number`
##### count
`number`
#### Returns
`Promise`\<`any`\>
***
### apiGetGroupLink()
> **apiGetGroupLink**(`groupId`): `Promise`\<`GroupLink`\>
Defined in: [src/api.ts:662](../src/api.ts#L662)
Get group link.
Network usage: no.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupLink`\>
***
### apiGetGroupLinkStr()
> **apiGetGroupLinkStr**(`groupId`): `Promise`\<`string`\>
Defined in: [src/api.ts:668](../src/api.ts#L668)
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`string`\>
***
### apiGetUserAddress()
> **apiGetUserAddress**(`userId`): `Promise`\<`UserContactLink` \| `undefined`\>
Defined in: [src/api.ts:366](../src/api.ts#L366)
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:541](../src/api.ts#L541)
Join group.
Network usage: interactive.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiLeaveGroup()
> **apiLeaveGroup**(`groupId`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:591](../src/api.ts#L591)
Leave group.
Network usage: background.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiListContacts()
> **apiListContacts**(`userId`): `Promise`\<`Contact`[]\>
Defined in: [src/api.ts:751](../src/api.ts#L751)
Get contacts.
Network usage: no.
#### Parameters
##### userId
`number`
#### Returns
`Promise`\<`Contact`[]\>
***
### apiListGroups()
> **apiListGroups**(`userId`, `contactId?`, `search?`): `Promise`\<`GroupInfo`[]\>
Defined in: [src/api.ts:761](../src/api.ts#L761)
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:601](../src/api.ts#L601)
Get group members.
Network usage: no.
#### Parameters
##### groupId
`number`
#### Returns
`Promise`\<`GroupMember`[]\>
***
### apiListUsers()
> **apiListUsers**(): `Promise`\<`UserInfo`[]\>
Defined in: [src/api.ts:859](../src/api.ts#L859)
Get all user profiles
Network usage: no.
#### Returns
`Promise`\<`UserInfo`[]\>
***
### apiNewGroup()
> **apiNewGroup**(`userId`, `groupProfile`): `Promise`\<`GroupInfo`\>
Defined in: [src/api.ts:611](../src/api.ts#L611)
Create group.
Network usage: no.
#### Parameters
##### userId
`number`
##### groupProfile
`GroupProfile`
#### Returns
`Promise`\<`GroupInfo`\>
***
### apiReceiveFile()
> **apiReceiveFile**(`fileId`): `Promise`\<`AChatItem`\>
Defined in: [src/api.ts:511](../src/api.ts#L511)
Receive file.
Network usage: no.
#### Parameters
##### fileId
`number`
#### Returns
`Promise`\<`AChatItem`\>
***
### apiRejectContactRequest()
> **apiRejectContactRequest**(`contactReqId`): `Promise`\<`void`\>
Defined in: [src/api.ts:741](../src/api.ts#L741)
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:581](../src/api.ts#L581)
Remove members. Requires Admin role.
Network usage: background.
#### Parameters
##### groupId
`number`
##### memberIds
`number`[]
##### withMessages?
`boolean` = `false`
#### Returns
`Promise`\<`GroupMember`[]\>
***
### apiSendMemberContactInvitation()
> **apiSendMemberContactInvitation**(`contactId`, `message?`): `Promise`\<`Contact`\>
Defined in: [src/api.ts:926](../src/api.ts#L926)
Send a direct message invitation to a group member contact.
The contact must have been created with [apiCreateMemberContact](#apicreatemembercontact).
Network usage: interactive.
#### Parameters
##### contactId
`number`
##### message?
`string` \| `MsgContent`
#### Returns
`Promise`\<`Contact`\>
***
### apiSendMessages()
> **apiSendMessages**(`chat`, `messages`, `liveMessage?`): `Promise`\<`AChatItem`[]\>
Defined in: [src/api.ts:415](../src/api.ts#L415)
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:437](../src/api.ts#L437)
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:445](../src/api.ts#L445)
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:869](../src/api.ts#L869)
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:398](../src/api.ts#L398)
Set bot address settings.
Network usage: interactive.
#### Parameters
##### userId
`number`
##### \_\_namedParameters
[`BotAddressSettings`](api.Interface.BotAddressSettings.md)
#### Returns
`Promise`\<`void`\>
***
### apiSetAutoAcceptMemberContacts()
> **apiSetAutoAcceptMemberContacts**(`userId`, `onOff`): `Promise`\<`void`\>
Defined in: [src/api.ts:808](../src/api.ts#L808)
Set auto-accept member contacts.
Network usage: no.
#### Parameters
##### userId
`number`
##### onOff
`boolean`
#### Returns
`Promise`\<`void`\>
***
### apiSetContactCustomData()
> **apiSetContactCustomData**(`contactId`, `customData?`): `Promise`\<`void`\>
Defined in: [src/api.ts:798](../src/api.ts#L798)
Set contact custom data.
Network usage: no.
#### Parameters
##### contactId
`number`
##### customData?
`object`
#### Returns
`Promise`\<`void`\>
***
### apiSetContactPrefs()
> **apiSetContactPrefs**(`contactId`, `preferences`): `Promise`\<`void`\>
Defined in: [src/api.ts:905](../src/api.ts#L905)
Configure chat preference overrides for the contact.
Network usage: background.
#### Parameters
##### contactId
`number`
##### preferences
`Preferences`
#### Returns
`Promise`\<`void`\>
***
### apiSetGroupCustomData()
> **apiSetGroupCustomData**(`groupId`, `customData?`): `Promise`\<`void`\>
Defined in: [src/api.ts:788](../src/api.ts#L788)
Set group custom data.
Network usage: no.
#### Parameters
##### groupId
`number`
##### customData?
`object`
#### Returns
`Promise`\<`void`\>
***
### apiSetGroupLinkMemberRole()
> **apiSetGroupLinkMemberRole**(`groupId`, `memberRole`): `Promise`\<`void`\>
Defined in: [src/api.ts:644](../src/api.ts#L644)
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:561](../src/api.ts#L561)
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:384](../src/api.ts#L384)
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:453](../src/api.ts#L453)
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:621](../src/api.ts#L621)
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:889](../src/api.ts#L889)
Update user profile.
Network usage: background.
#### Parameters
##### userId
`number`
##### profile
`Profile`
#### Returns
`Promise`\<`UserProfileUpdateSummary` \| `undefined`\>
***
### close()
> **close**(): `Promise`\<`void`\>
Defined in: [src/api.ts:148](../src/api.ts#L148)
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:287](../src/api.ts#L287)
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?
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`K`\> \| `undefined`
An optional subscriber function for the event.
#### Returns
`void`
***
### offAny()
> **offAny**(`receiver?`): `void`
Defined in: [src/api.ts:303](../src/api.ts#L303)
Unsubscribe all or a specific handler from any events.
#### Parameters
##### receiver?
[`EventSubscriberFunc`](api.TypeAlias.EventSubscriberFunc.md)\<`Tag`\> \| `undefined`
An optional subscriber function for the event.
#### Returns
`void`
***
### on()
#### Call Signature
> **on**\<`K`\>(`subscribers`): `void`
Defined in: [src/api.ts:197](../src/api.ts#L197)
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:205](../src/api.ts#L205)
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:228](../src/api.ts#L228)
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:239](../src/api.ts#L239)
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:338](../src/api.ts#L338)
#### Parameters
##### wait?
`number` = `5_000_000`
#### Returns
`Promise`\<`ChatEvent` \| `undefined`\>
***
### sendChatCmd()
> **sendChatCmd**(`cmd`): `Promise`\<`ChatResponse`\>
Defined in: [src/api.ts:334](../src/api.ts#L334)
#### Parameters
##### cmd
`string`
#### Returns
`Promise`\<`ChatResponse`\>
***
### startChat()
> **startChat**(): `Promise`\<`void`\>
Defined in: [src/api.ts:122](../src/api.ts#L122)
Start chat controller. Must be called with the existing user profile.
#### Returns
`Promise`\<`void`\>
***
### stopChat()
> **stopChat**(): `Promise`\<`void`\>
Defined in: [src/api.ts:136](../src/api.ts#L136)
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` & `object`\>
Defined in: [src/api.ts:247](../src/api.ts#L247)
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` & `object`\>
#### Call Signature
> **wait**\<`K`\>(`event`, `predicate`): `Promise`\<`ChatEvent` & `object`\>
Defined in: [src/api.ts:248](../src/api.ts#L248)
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` & `object`\>
#### Call Signature
> **wait**\<`K`\>(`event`, `timeout`): `Promise`\<ChatEvent & \{ type: K; \} \| `undefined`\>
Defined in: [src/api.ts:249](../src/api.ts#L249)
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:250](../src/api.ts#L250)
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**(`db`, `confirm?`): `Promise`\<`ChatApi`\>
Defined in: [src/api.ts:110](../src/api.ts#L110)
Initializes the ChatApi.
#### Parameters
##### db
[`DbConfig`](api.TypeAlias.DbConfig.md)
Database configuration (sqlite or postgres).
##### confirm?
[`MigrationConfirmation`](core.Enumeration.MigrationConfirmation.md) = `core.MigrationConfirmation.YesUp`
Migration confirmation mode.
#### Returns
`Promise`\<`ChatApi`\>