Represents a conversation inside some chat.

A conversation keeps track of any messages sent or edited since it was started and until it was stopped, and allows waiting for events in it.

If you need a conversation across multiple chats, you should use multiple Conversation objects and synchronize them manually.

Constructors

Properties

Accessors

Methods

  • Mark the conversation as read up to a certain point.

    By default, reads until the last message. You can pass message=null to read the entire conversation, or pass message ID to read up until that ID.

    Parameters

    • __namedParameters: {
          clearMentions?: boolean;
          message?: null | number;
      } = {}
      • OptionalclearMentions?: boolean
      • Optionalmessage?: null | number

    Returns Promise<void>

  • Wait for a message to be edited in the conversation. By defaults wait for the last message sent by the other party (at the moment) to be edited.

    Returns the edited message.

    Parameters

    • Optionalfilter: ((msg: Message) => MaybePromise<boolean>)

      Filter for the handler. You can use any filter you can use for dispatcher

    • Optionalparams: {
          message?: number;
          timeout?: null | number;
      }
      • Optionalmessage?: number

        Message for which to wait for reply for.

        last received message
        
      • Optionaltimeout?: null | number

        Timeout for the handler in ms. Pass null to disable.

        When the timeout is reached, TimeoutError is thrown.

        15000 (15 sec)

    Returns Promise<Message>

  • Wait for the message to be read by the other party.

    Note that reading the message doesn't mean the response was sent, and if the response was sent, it doesn't mean that the message was read.

    Parameters

    • Optionalmessage: number

      Message for which to wait for read for. Defaults to last message.

    • timeout: null | number = 15000

      Timeout for the handler in ms, def. 15 sec. Pass null to disable. When the timeout is reached, TimeoutError is thrown.

    Returns Promise<void>

  • Wait for the reply for the given message' (def. the last one) in the conversation.

    Parameters

    • Optionalfilter: ((msg: Message) => MaybePromise<boolean>)

      Filter for the handler. You can use any filter you can use for dispatcher

    • Optionalparams: {
          message?: number;
          timeout?: null | number;
      }
      • Optionalmessage?: number

        Message for which to wait for reply for.

        last sent/received message
        
      • Optionaltimeout?: null | number

        Timeout for the handler in ms. Pass null to disable.

        When the timeout is reached, TimeoutError is thrown.

        15000 (15 sec)

    Returns Promise<Message>

  • Wait for a response for the given message (def. the last one) in the conversation.

    A message is considered to be a response if it was sent after the given one.

    Parameters

    • Optionalfilter: ((msg: Message) => MaybePromise<boolean>)

      Filter for the handler. You can use any filter you can use for dispatcher

    • Optionalparams: {
          message?: number;
          timeout?: null | number;
      }
      • Optionalmessage?: number

        Message for which to wait for response for.

        last sent/received message
        
      • Optionaltimeout?: null | number

        Timeout for the handler in ms. Pass null to disable.

        When the timeout is reached, TimeoutError is thrown.

        15000 (15 sec)

    Returns Promise<Message>