Class Audio

Hierarchy (view full)

Constructors

Properties

duration: number

Duration of the audio in seconds as defined by sender

id: string

The unique identifier for this file

mimeType?: string

MIME type of the file as defined by sender

name?: string

Original filename as defined by sender

path: null | string

The path to the file on the Telegram server, if available

performer?: string

Performer of the audio as defined by sender or by audio tags

size: null | number

The size of the file in bytes, if available

thumbnail?: Photo

Thumbnail of the album cover to which the music file belongs

uniqueId: string

The unique identifier for this file, which is supposed to be consistent across different bots

Accessors

  • get url(): null | string
  • Gets the URL to access the file on the Telegram server.

    Returns null | string

Methods

  • Protected

    Creates a clone of the current instance

    Returns Base

    A clone of the current instance

  • Protected

    Patches the current instance with new data

    Parameters

    • data: Record<string, any>

      The data to patch the instance with

    Returns Record<string, any>

    The patched data

  • Protected

    Updates the current instance with new data and returns a clone of the updated instance

    Parameters

    • data: Record<string, any>

      The data to update the instance with

    Returns Base

    A clone of the updated instance

  • Downloads the file from the Telegram server.

    Returns Promise<Buffer>

    A promise that resolves with the file data as a Buffer.

  • Flatten an object. Any properties that are collections will get converted to an array of keys.

    Parameters

    • OptionalpropsRecursive: boolean

      Optional. If true, calls toJSON method on nested objects.

    • Rest...props: Record<string, string | boolean>[]

      Optional. Specific properties to include/exclude, or rename.

    Returns Record<string, any>

    Flattened object.

  • Returns the id instance Chat, User, ChatMember and other

    Returns null | string

  • Writes the file to the specified path.

    Parameters

    • path: string

      The path where the file should be written.

    • OptionalwriteType: "promise"

      The type of write operation.

    • Optionaloptions: {
          encoding?: BufferEncoding;
          flag?: string;
          signal?: AbortSignal;
      }

      Additional options for writing the file.

      • Optionalencoding?: BufferEncoding
      • Optionalflag?: string
      • Optionalsignal?: AbortSignal

    Returns Promise<void>

    A promise that resolves when the file has been written.

  • Writes the file to the specified path.

    Parameters

    • path: string

      The path where the file should be written.

    • writeType: "stream"

      The type of write operation.

    • Optionaloptions: {
          autoClose?: boolean;
          emitClose?: boolean;
          encoding?: BufferEncoding;
          flush?: boolean;
          highWaterMark?: number;
          start?: number;
      }

      Additional options for writing the file.

      • OptionalautoClose?: boolean
      • OptionalemitClose?: boolean
      • Optionalencoding?: BufferEncoding
      • Optionalflush?: boolean
      • OptionalhighWaterMark?: number
      • Optionalstart?: number

    Returns Promise<void>

    A promise that resolves when the file has been written.

  • Writes the file to the specified path.

    Parameters

    • path: string

      The path where the file should be written.

    • OptionalwriteType: "stream" | "promise"

      The type of write operation.

    • Optionaloptions: undefined

      Additional options for writing the file.

    Returns Promise<void>

    A promise that resolves when the file has been written.