Class MessageManager
Hierarchy
- EventBasedManager<MessageEvents>
- MessageManager (view full)
Accessors
log
- get log(): MessageLog
Returns a shallow copy of all logged chat messages.
If the messages length is greater than ClientOptions.maximumMessages, the oldest messages are spliced out.
Returns MessageLog
Methods
off
- off<Event>(event, listener): this
Removes an existing event listener.
Type Parameters
Parameters
- event: Event
The event name associated with this listener to remove.
- listener: ((...args: MessageEvents[Event]) => void)
The callback function to remove.
- (...args): void
Parameters
Rest
...args: MessageEvents[Event]
Returns void
Returns this
This object.
- event: Event
on
- on<Event>(event, listener): this
Add an event listener for a specific event.
Type Parameters
Parameters
- event: Event
The event name to listen for.
- listener: ((...args: MessageEvents[Event]) => void)
The callback function to fire when this event is received.
- (...args): void
Parameters
Rest
...args: MessageEvents[Event]
Returns void
Returns this
This object.
- event: Event
say
- say(text): Promise<void>
Sends a chat message to the server.
Parameters
- text: string
The textual message to broadcast to all connected clients.
Returns Promise<void>
A promise that resolves when the server has broadcast the chat message.
Throws
UnauthenticatedError if attempting to send a chat message when not connected or authenticated.
- text: string
wait
- wait<Event>(event, clearPredicate?): Promise<MessageEvents[Event]>
Returns a promise that waits for a single specified event to be received. Resolves with the list of arguments dispatched with the event.
Type Parameters
Parameters
- event: Event
The event name to listen for.
- clearPredicate: ((...args: MessageEvents[Event]) => boolean) = ...
An optional predicate to check on incoming events to validate if the correct event has been received. If omitted, will return immediately on next event type received.
- (...args): boolean
Parameters
Rest
...args: MessageEvents[Event]
Returns boolean
Returns Promise<MessageEvents[Event]>
- event: Event
Manages and stores PrintJSONPacket messages, notifies subscribers of new messages, and exposes helper methods to interact with the chat system.