Skip to main content

API References

This section provides a brief overview of the primary classes and structures in the mezon-sdk. For detailed type information, refer to the TypeScript definitions within the SDK source (src/interfaces/ and src/mezon-client/structures/).

MezonClient (MezonClient.ts)

The primary class for interacting with the Mezon API and real-time events. It manages the connection, data caching, and event handling.

Key Properties

PropertyTypeDescription
tokenstringThe authentication token for the client.
clientIdstring | undefinedThe ID of the logged-in client (bot/user), set after authentication.
hoststringThe hostname of the Mezon server.
useSSLbooleanIndicates if the connection uses SSL/TLS.
portstringThe port used for the connection.
loginBasePathstring | undefinedThe base path used for initial authentication.
timeoutnumberRead-only. The timeout in milliseconds for API requests.
clansCacheManager<string, Clan>A cache manager for all clans the client has access to.
channelsCacheManager<string, TextChannel>A cache manager for all channels the client has access to.

Key Private Properties

PropertyTypeDescription
apiClientMezonApiAn instance of the MezonApi for making direct API calls.
socketManagerSocketManagerManages the WebSocket connection and its lifecycle.
channelManagerChannelManagerManages channel-related operations, particularly DM channels.
sessionManagerSessionManagerManages the client's session and authentication.
eventManagerEventManagerHandles the subscription and emission of events.
messageQueueAsyncThrottleQueueRate-limited queue for managing outgoing requests.
messageDBMessageDatabaseAn interface to the local SQLite database for message storage.

Key Methods

constructor(token?, host?, port?, useSSL?, timeout?)

Initializes a new MezonClient instance.

ParameterTypeDefaultDescription
tokenstring""The API key for authentication.
hoststring"gw.mezon.ai"The host address of the Mezon gateway.
portstring"443"The port number for the connection.
useSSLbooleanTRUESpecifies whether to use a secure SSL connection.
timeoutnumber7000The timeout in milliseconds for API requests.

login(): Promise<string>

Authenticates the client with the Mezon service, establishes a WebSocket connection, and initializes all necessary managers and caches. It emits the ready event upon successful connection.

sendToken(sendTokenData: TokenSentEvent): Promise<any>

Sends a specified amount of a token to another user.

ParameterTypeDefaultDescription
sendTokenDataTokenSentEvent""The details of the token transfer.

getListFriends(limit?: number, state?: string, cursor?: string): Promise<any>

Retrieves a list of the client's friends.

ParameterTypeDefaultDescription
limitnumber""(Optional) The maximum number of friends to retrieve.
statestring""(Optional) The friendship state to filter by (e.g., "accepted").
cursorstring""(Optional) The cursor for pagination.

addFriend(username: string): Promise<any>

Sends a friend request to a user by their username.

ParameterTypeDescription
usernamestringThe username of the user to add as a friend.

acceptFriend(userId: string, username: string): Promise<any>

Accepts a friend request from a user.

ParameterTypeDescription
userIdstringThe ID of the user whose friend request to accept.
usernamestringThe username of the user.

createDMchannel(userId: string): Promise<ApiChannelDescription | null>

Creates a direct message channel with a specific user.

ParameterTypeDescription
userIdstringThe ID of the user to create a DM channel with.

closeSocket(): void

Closes the WebSocket connection and resets the event manager.

initManager(basePath: string, sessionApi?: Session): void

Initializes all internal managers after authentication. This is called automatically by login().

ParameterTypeDescription
basePathstringThe base URL for API requests.
sessionApiSession(Optional) An existing session to restore.

Key Events Handling

Message Events

  • onChannelMessage(listener: (e: ChannelMessage) => void): this: Listens for new messages in any channel/thread the client is in.

  • onMessageReaction(listener: (e: MessageReaction) => void): this: Listens for reactions being added or removed from a message.

  • onMessageButtonClicked(listener: (e: MessageButtonClicked) => void): this: Listens for clicks on buttons within embed messages.

  • onDropdownBoxSelected(listener: (e: DropdownBoxSelected) => void): this: Listens for a user selecting an option from a dropdown menu in a message.

Channel Events

  • onChannelCreated(listener: (e: ChannelCreatedEvent) => void): this: Listens for the creation of a new channel.

  • onChannelUpdated(listener: (e: ChannelUpdatedEvent) => void): this: Listens for updates to an existing channel's information.

  • onChannelDeleted(listener: (e: ChannelDeletedEvent) => void): this: Listens for the deletion of a channel.

User & Clan Events

  • onAddClanUser(listener: (e: AddClanUserEvent) => void): this: Listens for a user being added to a clan.

  • onUserClanRemoved(listener: (e: UserClanRemovedEvent) => void): this: Listens for a user being removed or leaving a clan.

  • onUserChannelAdded(listener: (e: UserChannelAddedEvent) => void): this: Listens for a user being added to a channel.

  • onUserChannelRemoved(listener: (e: UserChannelRemoved) => void): this: Listens for a user being removed from a channel.

Role Events

  • onRoleEvent(listener: (e: RoleEvent) => void): this: Listens for the creation or update of a role in a clan.

  • onRoleAssign(listener: (e: RoleAssignedEvent) => void): this: Listens for a role being assigned to a user.

Voice & Streaming Events

  • onVoiceStartedEvent(listener: (e: VoiceStartedEvent) => void): this: Listens for the start of a voice chat.

  • onVoiceEndedEvent(listener: (e: VoiceEndedEvent) => void): this: Listens for the end of a voice chat.

  • onVoiceJoinedEvent(listener: (e: VoiceJoinedEvent) => void): this: Listens for a user joining a voice chat.

  • onVoiceLeavedEvent(listener: (e: VoiceLeavedEvent) => void): this: Listens for a user leaving a voice chat.

  • onStreamingJoinedEvent(listener: (e: StreamingJoinedEvent) => void): this: Listens for a user joining a stream.

  • onStreamingLeavedEvent(listener: (e: StreamingLeavedEvent) => void): this: Listens for a user leaving a stream.

  • onWebrtcSignalingFwd(listener: (e: WebrtcSignalingFwd) => void): this: Listens for WebRTC signaling events, typically for P2P calls.

Other Events

  • onTokenSend(listener: (e: TokenSentEvent) => void): this: Listens for token transfer events between users.

  • onGiveCoffee(listener: (e: GiveCoffeeEvent) => void): this: Listens for "give coffee" events.

  • onClanEventCreated(listener: (e: CreateEventRequest) => void): this: Listens for the creation of a new clan event.

  • onNotification(listener: (e: Notifications) => void): this: Listens for incoming notifications for the client.

  • onQuickMenuEvent(listener: (e: QuickMenuEvent) => void): this: Listens for quick menu interaction events.

Session (session.ts, session_manager.ts)

This API reference outlines the key components for handling user sessions with the Mezon server.

ISession Interface: Defines the contract for a user session, containing tokens, expiry information, and user details.

Session Class: A concrete implementation of the ISession interface. It provides methods to create, manage, and update a user session from JWT tokens.

Session Class

Key Properties

PropertyTypeDescription
tokenstringThe JWT authorization token for the session.
created_atnumberRead-only. The UNIX timestamp marking when the session was created.
expires_atnumber?(Optional) The UNIX timestamp when the token will expire.
refresh_expires_atnumber?(Optional) The UNIX timestamp when the refresh_token will expire.
refresh_tokenstringThe token used to obtain a new session token when the current one expires.
user_idstring?(Optional) The ID of the user associated with this session.
varsobject?(Optional) A key-value object of custom properties associated with the session.
api_urlstring?(Optional) The base URL for API requests, provided during authentication.

Key Methods

constructor

new Session(apiSession: any): Initializes a new Session instance.

ParameterTypeDescription
apiSessionanyAn object containing session data, typically from an authentication response. Must include token and refresh_token.

new SessionManager(apiClient: MezonApi, session?: Session): Initializes a new SessionManager instance.

ParameterTypeDescription
apiClientMezonApiAn instance of the MezonApi class used to make authentication requests.
sessionSession(Optional) An existing Session object to restore.

For Session

isexpired(currenttime: number): boolean

Checks if the session token has expired relative to the provided time.

ParameterTypeDescription
currenttimenumberThe current UNIX timestamp to compare against the session's expiry.

isrefreshexpired(currenttime: number): boolean

Checks if the refresh token has expired relative to the provided time.

ParameterTypeDescription
currenttimenumberThe current UNIX timestamp to compare against the refresh token's expiry.

update(token: string, refreshToken: string): void

Updates the session with a new token and refreshToken. This method decodes the tokens to update expiry times and other session variables.

ParameterTypeDescription
tokenstringThe new JWT session token.
refreshTokenstringThe new JWT refresh token.

static restore(session: any): Session

A static factory method that creates a new Session instance from a previously stored session object. This is useful for rehydrating a session from local storage.

ParameterTypeDescription
sessionanyA plain object representing a stored session.

SessionManager Class

The SessionManager handles authentication and session lifecycle management.

Key Properties

PropertyTypeDescription
apiClientMezonApiPrivate. The API client used for authentication.
sessionSession?Private. The currently active session, if any.

Key Methods

constructor(apiClient: MezonApi, session?: Session)

Initializes a new SessionManager instance.

ParameterTypeDescription
apiClientMezonApiAn instance of the MezonApi class used to make authentication requests.
sessionSession?(Optional) An existing Session object to restore.

authenticate(apiKey: string): Promise<Session>

Authenticates the user with the Mezon server using an API key. On success, it creates and stores a new Session object.

ParameterTypeDescription
apiKeystringThe API key used for authentication.

logout(): Promise<boolean>

Logs out the currently authenticated user by invalidating the session and refresh tokens on the server.

getSession(): Session | undefined

Retrieves the currently stored session object.

TextChannel (TextChannel.ts)

This API reference outlines the key components of the TextChannel class, which represents a text-based communication channel within a clan.

Key Properties

PropertyTypeDescription
idstring?The unique identifier for the channel.
namestring?The display name of the channel.
is_privatebooleantrue if the channel is private, otherwise false.
channel_typenumber?The type of the channel (e.g., standard text, thread).
category_idstring?The ID of the category this channel belongs to.
category_namestring?The name of the category this channel belongs to.
parent_idstring?The ID of the parent channel, if this is a thread.
meeting_codestring?The meeting code for voice channels.
clanClanA reference to the parent Clan instance.
messagesCacheManager<string, Message>A cache manager for the messages within this channel.

Key Private Properties

PropertyTypeDescription
socketManagerSocketManagerThe manager for handling WebSocket communications.
messageQueueAsyncThrottleQueueA queue to manage the rate of outgoing messages.
messageDBMessageDatabaseThe database interface for caching and retrieving messages.

Key Methods

constructor(initChannelData, clan, socketManager, messageQueue, messageDB)

Initializes a new TextChannel instance.

ParameterTypeDescription
initChannelDataApiChannelDescriptionAn object containing the initial channel data from the API.
clanClanThe parent Clan object that this channel belongs to.
socketManagerSocketManagerThe manager for handling WebSocket communications.
messageQueueAsyncThrottleQueueA queue to manage the rate of outgoing messages.
messageDBMessageDatabaseThe database interface for caching and retrieving messages.

send(content, mentions?, attachments?, mention_everyone?, anonymous_message?, topic_id?, code?)

Sends a standard message to the channel. The request is added to a queue to prevent rate-limiting issues.

ParameterTypeDescription
contentChannelMessageContentThe content of the message to be sent.
mentionsArray<ApiMessageMention>(Optional) An array of user mentions to include in the message.
attachmentsArray<ApiMessageAttachment>(Optional) An array of attachments (e.g., images, files) to include.
mention_everyoneboolean(Optional) Whether to notify everyone in the channel.
anonymous_messageboolean(Optional) Whether to send the message anonymously.
topic_idstring(Optional) The ID of the topic (thread) this message belongs to.
codenumber(Optional) A special code associated with the message type.

sendEphemeral(receiver_id, content, reference_message_id?, mentions?, attachments?, mention_everyone?, anonymous_message?, topic_id?, code?)

Sends an ephemeral message, which is visible only to a specific user (receiver_id) within the channel.

ParameterTypeDescription
receiver_idstringThe ID of the user who will be able to see the message.
contentanyThe content of the ephemeral message.
reference_message_idstring?(Optional) The ID of a message to reply to.
mentionsArray<ApiMessageMention>?(Optional) An array of user mentions.
attachmentsArray<ApiMessageAttachment>?(Optional) An array of attachments.
mention_everyoneboolean?(Optional) Whether to parse everyone mentions.
anonymous_messageboolean?(Optional) Whether to send the message anonymously.
topic_idstring?(Optional) The ID of the topic (thread) this message belongs to.
codenumber?(Optional) A special code associated with the message type.

addQuickMenuAccess(body: ApiQuickMenuAccessPayload): Promise<any>

Adds a quick menu access for the channel.

ParameterTypeDescription
bodyApiQuickMenuAccessPayloadThe quick menu configuration payload.

deleteQuickMenuAccess(botId?: string): Promise<any>

Removes quick menu access for the channel.

ParameterTypeDescription
botIdstring?(Optional) The bot ID. Defaults to client ID.

playMedia(url: string, participantIdentity: string, participantName: string, name: string): Promise<any>

Plays media in a voice channel.

ParameterTypeDescription
urlstringThe URL of the media to play.
participantIdentitystringThe participant's identity.
participantNamestringThe participant's display name.
namestringThe name/title of the media.

Message (Message.ts)

This API reference outlines the key components for representing and interacting with individual messages within a text channel.

MessageInitData Interface

Defines the structure for the data object required to initialize a Message instance.

PropertyTypeDescription
idstringThe unique identifier of the message.
clan_idstringThe ID of the clan this message belongs to.
channel_idstringThe ID of the channel this message belongs to.
sender_idstringThe ID of the user who sent the message.
contentChannelMessageContentThe main content of the message.
mentionsApiMessageMention[]?(Optional) An array of user mentions.
attachmentsApiMessageAttachment[]?(Optional) An array of attachments.
reactionsApiMessageReaction[]?(Optional) An array of reactions on the message.
referencesApiMessageRef[]?(Optional) An array of referenced messages.
topic_idstring?(Optional) The ID of the topic this message is in.
create_time_secondsnumber?(Optional) The UNIX timestamp of message creation.

Message Class

Represents a single message in a channel, containing its content and metadata. It provides methods to perform actions on the message, such as replying, updating, reacting, and deleting.

Key Properties

PropertyTypeDescription
idstringThe unique identifier of the message.
sender_idstringThe ID of the user who sent the message.
contentChannelMessageContentThe main content of the message.
mentionsApiMessageMention[](Optional) An array of user mentions.
attachmentsApiMessageAttachment[](Optional) An array of attachments.
reactionsApiMessageReaction[](Optional) An array of reactions on the message.
referencesApiMessageRef[](Optional) An array of messages this message is referencing.
topic_idstring(Optional) The ID of the topic (thread) this message is part of.
create_time_secondsnumber(Optional) The UNIX timestamp of the message's creation.
channelTextChannelA reference to the parent TextChannel instance.

Key Methods

constructor(initMessageData, channel, socketManager, messageQueue)

Initializes a new Message instance.

ParameterTypeDescription
initMessageDataMessageInitDataAn object containing the initial message data.
channelTextChannelThe parent TextChannel object where this message exists.
socketManagerSocketManagerThe manager for handling WebSocket communications.
messageQueueAsyncThrottleQueueA queue to manage the rate of outgoing actions on the message.

reply(content, mentions?, attachments?, mention_everyone?, anonymous_message?, topic_id?, code?)

Sends a new message in the same channel, specifically as a reply to this message instance.

ParameterTypeDescription
contentChannelMessageContentThe content of the reply message.
mentionsArray<ApiMessageMention>(Optional) An array of user mentions to include.
attachmentsArray<ApiMessageAttachment>(Optional) An array of attachments to include.
mention_everyoneboolean(Optional) Whether to notify everyone in the channel.
anonymous_messageboolean(Optional) Whether to send the reply anonymously.
topic_idstring(Optional) The ID of the topic for the reply. Defaults to the original message's topic.
codenumber(Optional) A special code for the message type.

update(content, mentions?, attachments?, topic_id?)

Updates the content of this message.

ParameterTypeDescription
contentChannelMessageContentThe new content for the message.
mentionsArray<ApiMessageMention>?(Optional) Updated mentions.
attachmentsArray<ApiMessageAttachment>?(Optional) Updated attachments.
topic_idstring?(Optional) The new topic ID for the message.

react(dataReactMessage: ReactMessagePayload): Promise<any>

Adds or removes a reaction to/from this message.

ParameterTypeDescription
dataReactMessageReactMessagePayloadAn object containing the details of the reaction, such as the emoji and whether to add or remove it.

delete(): Promise<any>

Deletes this message from the channel.

User (User.ts)

This API reference outlines the key components for representing a user and interacting with them.

UserInitData Interface

Defines the structure for the data object required to initialize a User instance.

PropertyTypeDescription
idstringThe unique identifier for the user.
usernamestring?(Optional) The user's global username.
clan_nickstring?(Optional) The user's nickname in the clan context.
clan_avatarstring?(Optional) The user's avatar URL in the clan context.
display_namestring?(Optional) The user's public display name.
avartarstring?(Optional) The user's global avatar URL.
dmChannelIdstring?(Optional) The ID of the DM channel with this user.

User Class

Represents a user within the system, holding their profile information and providing methods for direct interaction, such as sending direct messages or tokens.

Key Properties

PropertyTypeDescription
idstringThe unique identifier for the user.
usernamestringThe user's global username.
clan_nickstringThe user's nickname specific to the clan context.
clan_avatarstringThe user's avatar URL specific to the clan context.
display_namestringThe user's public display name.
avartarstringThe user's global avatar URL.
dmChannelIdstringThe ID of the direct message channel with this user.

Key Private Properties

PropertyTypeDescription
clanClanThe clan context this user instance belongs to.
channelManagerChannelManager?(Optional) Manager for channel operations, used for creating DMs.
messageQueueAsyncThrottleQueueRate-limited queue for managing outgoing requests.
socketManagerSocketManagerThe manager for handling WebSocket communications.

Key Methods

constructor(initUserData, clan, messageQueue, socketManager, channelManager?)

Initializes a new User instance.

ParameterTypeDescription
initUserDataUserInitDataAn object containing the initial user data.
clanClanThe Clan object this user instance is associated with.
messageQueueAsyncThrottleQueueA queue to manage the rate of outgoing messages.
socketManagerSocketManagerThe manager for handling WebSocket communications.
channelManagerChannelManager(Optional) The manager for handling channel operations, required for creating DMs.

sendToken(sendTokenData: SendTokenData): Promise<any>

Sends a specified amount of a token to this user.

ParameterTypeDescription
sendTokenDataSendTokenDataAn object containing the amount and an optional note for the transaction.

sendDM(content: ChannelMessageContent, code?: number): Promise<any>

Sends a direct message to this user. If a DM channel does not already exist, it will attempt to create one first.

ParameterTypeDescription
contentChannelMessageContentThe content of the message to be sent.
codenumber?(Optional) A special code associated with the message type.

createDmChannel(): Promise<ApiChannelDescription | null>

Explicitly creates a new direct message channel with this user.

listTransactionDetail(transactionId: string): Promise<any>

Retrieves the details of a specific transaction involving the user.

ParameterTypeDescription
transactionIdstringThe unique identifier of the transaction to retrieve.

Clan (Clan.ts)

This API reference outlines the key components for representing a "Clan" (or server/guild) and managing its resources like channels, users, and roles.

ClanInitData Interface

Defines the structure for the data object required to initialize a Clan instance.

PropertyTypeDescription
idstringThe unique identifier for the clan.
namestringThe display name of the clan.
welcome_channel_idstringThe ID of the default welcome channel.

Clan Class

Represents a clan, which acts as a top-level container for a community's channels and users. It provides methods to fetch and manage these resources.

Key Properties

PropertyTypeDescription
idstringThe unique identifier for the clan.
namestringThe display name of the clan.
welcome_channel_idstringThe ID of the default welcome channel.
channelsCacheManager<string, TextChannel>A cache manager for the channels belonging to this clan.
usersCacheManager<string, User>A cache manager for the users who are members of this clan.
sessionTokenstringThe session token used for API requests in the context of this clan.
apiClientMezonApiThe API client instance used for making requests.

Key Private Properties

PropertyTypeDescription
_channelsLoadedbooleanPrivate. Cache status for loaded channels.
_loadingPromisePromise<void>?Private. Promise for ongoing channel loading process.
clientMezonClientPrivate. Reference to the main client instance.
socketManagerSocketManagerPrivate. The WebSocket manager.
messageQueueAsyncThrottleQueuePrivate. Rate-limited message queue.
messageDBMessageDatabasePrivate. Local message database interface.

Key Methods

constructor(initClanData, client, apiClient, socketManager, sessionToken, messageQueue, messageDB)

Initializes a new Clan instance.

ParameterTypeDescription
initClanDataClanInitDataAn object containing the initial clan data.
clientMezonClientThe main MezonClient instance.
apiClientMezonApiAn instance of the API client for making server requests.
socketManagerSocketManagerThe manager for handling WebSocket communications.
sessionTokenstringThe session token used for authenticating API calls.
messageQueueAsyncThrottleQueueA queue to manage the rate of outgoing messages.
messageDBMessageDatabaseThe database interface for caching and retrieving messages.

getClientId(): string | undefined

Returns the client ID (bot's user ID) from the main client instance.

loadChannels(): Promise<void>

Fetches and caches all text channels associated with the clan from the server. This method ensures it only runs once to prevent redundant API calls.

listChannelVoiceUsers(channel_id?, channel_type?, limit?, state?, cursor?): Promise<ApiVoiceChannelUserList>

Retrieves a list of users currently present in a specific voice channel within the clan.

ParameterTypeDefaultDescription
channel_idstring?""(Optional) The ID of the voice channel.
channel_typenumber?ChannelType.CHANNEL_TYPE_GMEET_VOICE(Optional) The type of voice channel.
limitnumber?500(Optional) Max users to return (must be between 1 and 500).
statenumber?undefined(Optional) A state filter for the user list.
cursorstring?undefined(Optional) The cursor for paginating through results.

updateRole(roleId: string, request: MezonUpdateRoleBody): Promise<boolean>

Updates the properties of a specific role within the clan.

ParameterTypeDescription
roleIdstringThe unique identifier of the role to update.
requestMezonUpdateRoleBodyAn object containing the new properties for the role.

listRoles(limit?: string, state?: string, cursor?: string): Promise<ApiRoleListEventResponse>

Retrieves a list of all roles available in the clan.

ParameterTypeDescription
limitstring(Optional) The maximum number of roles to return.
statestring(Optional) A state filter for the role list.
cursorstring(Optional) The cursor for paginating through results.

Common Interfaces and Types

ChannelMessageContent

Defines the structure for message content.

PropertyTypeDescription
tstring?(Optional) The main text content of the message.
hgHashtagOnMessage[]?(Optional) Array of hashtag references.
ejEmojiOnMessage[]?(Optional) Array of emoji references.
lkLinkOnMessage[]?(Optional) Array of link references.
mkMarkdownOnMessage[]?(Optional) Array of markdown formatting.
vkLinkVoiceRoomOnMessage[]?(Optional) Array of voice room links.
embedIInteractiveMessageProps[]?(Optional) Array of embedded content.
componentsIMessageActionRow[]?(Optional) Array of interactive components.

SendTokenData

Defines the structure for token transfer data.

PropertyTypeDescription
amountnumberThe amount of tokens to send.
notestring?(Optional) A note or description for the transfer.
extra_attributestring?(Optional) Additional metadata for the transfer.

TokenSentEvent

Represents a token transfer event.

PropertyTypeDescription
sender_idstring?(Optional) The ID of the user sending tokens.
sender_namestring?(Optional) The name of the user sending tokens.
receiver_idstringThe ID of the user receiving tokens.
amountnumberThe amount of tokens being transferred.
notestring?(Optional) A note attached to the transfer.
extra_attributestring?(Optional) Additional metadata.
transaction_idstring?(Optional) The unique transaction identifier.

ReactMessagePayload

Defines the structure for message reactions.

PropertyTypeDescription
idstring?(Optional) The unique identifier of the reaction.
emoji_idstringThe identifier of the emoji.
emojistringThe emoji character or string.
countnumberThe count of this reaction (managed by server).
action_deleteboolean?(Optional) true to remove, false to add (default).

ApiChannelDescription

Represents channel metadata and properties.

PropertyTypeDescription
channel_idstring?(Optional) The unique identifier of the channel.
channel_labelstring?(Optional) The display name of the channel.
clan_idstring?(Optional) The ID of the clan this channel belongs to.
typenumber?(Optional) The type of channel.
channel_privatenumber?(Optional) Whether the channel is private (1) or not (0).
category_idstring?(Optional) The ID of the category.
category_namestring?(Optional) The name of the category.
parent_idstring?(Optional) The ID of the parent channel.
meeting_codestring?(Optional) The meeting code for voice channels.
creator_idstring?(Optional) The ID of the channel creator.
create_time_secondsnumber?(Optional) The creation timestamp.
update_time_secondsnumber?(Optional) The last update timestamp.

Constants and Enums

ChannelType

Defines the different types of channels available in Mezon.

ConstantValueDescription
CHANNEL_TYPE_CHANNEL1Standard text channel
CHANNEL_TYPE_GROUP2Group channel
CHANNEL_TYPE_DM3Direct message channel
CHANNEL_TYPE_GMEET_VOICE4Google Meet voice channel
CHANNEL_TYPE_FORUM5Forum channel
CHANNEL_TYPE_STREAMING6Streaming channel
CHANNEL_TYPE_THREAD7Thread channel
CHANNEL_TYPE_APP8Application channel
CHANNEL_TYPE_ANNOUNCEMENT9Announcement channel
CHANNEL_TYPE_MEZON_VOICE10Mezon native voice channel

ChannelStreamMode

Defines the streaming modes for different channel types.

ConstantValueDescription
STREAM_MODE_CHANNEL2Channel stream mode
STREAM_MODE_GROUP3Group stream mode
STREAM_MODE_DM4Direct message stream mode
STREAM_MODE_CLAN5Clan stream mode
STREAM_MODE_THREAD6Thread stream mode

TypeMessage

Defines different message types and their purposes.

ConstantValueDescription
Chat0Standard chat message
ChatUpdate1Updated chat message
ChatRemove2Removed chat message
Typing3Typing indicator
Indicator4Status indicator
Welcome5Welcome message
CreateThread6Thread creation message
CreatePin7Pin creation message
MessageBuzz8Buzz/notification message
Topic9Topic message
AuditLog10Audit log message
SendToken11Token transfer message
Ephemeral12Ephemeral (temporary) message

Events

All available event types for the MezonClient event listeners.

Event NameDescription
ChannelMessageNew message received in a channel
MessageReactionReaction added/removed from a message
UserChannelRemovedUser removed from a channel
UserClanRemovedUser removed from a clan
UserChannelAddedUser added to a channel
ChannelCreatedNew channel created
ChannelDeletedChannel deleted
ChannelUpdatedChannel information updated
RoleEventRole created or updated
GiveCoffeeCoffee given between users
RoleAssignRole assigned to user
AddClanUserUser added to clan
TokenSendToken transfer between users
ClanEventCreatedClan event created
MessageButtonClickedInteractive button clicked
StreamingJoinedEventUser joined streaming session
StreamingLeavedEventUser left streaming session
DropdownBoxSelectedDropdown option selected
WebrtcSignalingFwdWebRTC signaling for voice/video calls
VoiceStartedEventVoice session started
VoiceEndedEventVoice session ended
VoiceJoinedEventUser joined voice channel
VoiceLeavedEventUser left voice channel
NotificationsGeneral notifications received
QuickMenuQuick menu interaction

Usage Notes

  • Rate Limiting: All message sending operations use AsyncThrottleQueue to prevent rate limiting.
  • Caching: The SDK extensively uses CacheManager for efficient data access and reduced API calls.
  • Authentication: Dynamic endpoint resolution ensures optimal server routing after authentication.
  • Event Handling: All events are automatically processed and cached appropriately.
  • Error Handling: Most methods return promises that should be properly handled with try-catch blocks.
  • TypeScript: The SDK is fully typed with TypeScript for better development experience.