Chat
index
methods
Methods
addUsers
addUsers (channelId: string, users: string[]) : Promise<Status> ;add users to channel
emits user:add event
Parameters
channelId
channel id
stringusers
an array of user ids
string[]Returns
Promise<Status>configure
configure (channelId: string, config: ChatConfig) : Promise<Status> ;update channel configuration
emits cnl:config event
Parameters
channelId
channel id
stringReturns
Promise<Status>create
create (channelId: string, config?: ChatConfig) : Promise<Status> ;create a new channel
emits cnl:add event
Parameters
channelId
channel id
stringReturns
Promise<Status>delUsers
delUsers (channelId: string, users: string[]) : Promise<Status> ;remove user from channel
users removed won't be able to join again unless added
emits user:del event
Parameters
channelId
channel id
stringusers
an array of user ids
string[]Returns
Promise<Status>delete
delete (channelId: string, reason?: string) : Promise<Status> ;delete a channel
emits cnl:del event
Parameters
channelId
channel id
stringreason ?
optionally tell others the reason
stringReturns
Promise<Status>deleteMessage
deleteMessage (channelId: string, messageId: string, soft?: boolean) : Promise<Status> ;delete a message
Parameters
channelId
channel id
stringmessageId
message id
stringsoft ?
either delete message completely or replace with deleted message
booleanReturns
true if deleted else false | rejects if not message author
Promise<Status>editMessage
editMessage (channelId: string, messageId: string, content: string) : Promise<Status> ;edit a message
Parameters
channelId
channel id
stringmessageId
message id
stringcontent
new message
stringReturns
status response | rejects if not message author
Promise<Status>get
get (channelId: string) : Promise<any> ;get channel info
Parameters
channelId
channel id
stringReturns
Promise<any>getMessages
getMessages (start: string | Date, limit?: number, channels?: string | string[], direction?: "reverse" | "forward") : Promise<{ [channelId : string] : Message[] }> ;Get messages in a channel(s) | if no channel id is provided saved messages from all user channels are returned by default 50 per query and a max of 150 at once
useful when scrolling through old messages not in user's device
this works only when cloud storage is enabled
Parameters
start
start from, can be either a message id or a date to start get from
string | Datelimit ?
number of messages | defaults to 50
numberchannels ?
channel id , if undefined returns messages from all user's saved channels undefined by default
you can also specify a channel or an array of channels to get messages from.
string | string[]direction ?
direction to fecth message either forward or reverse
"reverse" | "forward"Returns
messages in channels grouped by channel id
Promise<{ [channelId : string] : Message[] }>getUsers
getUsers (channelId: string) : Promise<User[]> ;get channel users
Parameters
channelId
channel id
stringReturns
users in channel
Promise<User[]>join
join (channelId: string) : Promise<any> ;join an existing channel
emits user:join event
Parameters
channelId
channel id
stringReturns
Promise<any>leave
leave (channelId: string) : Promise<Status> ;leave a channel
emits user:left event
Parameters
channelId
channel id
stringReturns
Promise<Status>list
list (pagination?: Pagination, publicOnly?: boolean) : Promise<any[]> ;list channels
Parameters
publicOnly ?
list public channels, when channel discovery is enabled. by default this is false and will alway return the user's joined channels
booleanReturns
Promise<any[]>modUsers
modUsers (channelId: string, users: string[], mode: number) : Promise<Status> ;moderate users in channel
emits user:mod event
check concepts for more about permissions
Parameters
channelId
channel id
stringusers
an array of users
string[]mode
numberReturns
Promise<Status>on
on < K extends keyof ChatEventMap > (event: K, handler: (ev: ChatEventMap[K]) => any ) : void ;listen for chat events and messages
Parameters
Returns
voidreact
react (channelId: string, messageId: string, reaction: string) : Promise<{ id: string; }> ;send a reaction to a message
Parameters
channelId
channel id
stringmessageId
message id
stringreaction
reaction
stringReturns
the derivery status of the message
Promise<{ id: string; }>send
send (channelId: string, message: string | SendMessage) : Promise<{ id: string; }> ;send a message in a channel
Parameters
channelId
channel id
stringReturns
the message id
Promise<{ id: string; }>