Class Poll

Hierarchy (view full)

Constructors

Properties

allowAnswers: boolean

True, if the poll allows multiple answers

anonymous: boolean

True, if the poll is anonymous

closeUnixTime?: number

Point in time (Unix timestamp) when the poll will be automatically closed

closed: boolean

True, if the poll is closed

correctId?: number

0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot

explanation?: string

Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters

explanationEntities?: MessageEntities

Special entities like usernames, URLs, bot commands, etc. that appear in the explanation

id: string

Unique poll identifier

openPeriod?: number

Amount of time in seconds the poll will be active after creation

options?: {
    entities: MessageEntities;
    text: string;
    voterCount: number;
}[]

List of poll options

Type declaration

  • entities: MessageEntities
    • Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts
  • text: string
    • Option text, 1-100 characters
  • voterCount: number
    • Number of users that voted for this option
question: string

Poll question, 1-300 characters

questionEntities?: MessageEntities

Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions

totalVoterCount: number

Total number of users that voted in the poll

type: "quiz" | "regular"

Poll type, currently can be “regular” or “quiz”

Accessors

  • get closeTimestamp(): null | number
  • Return the timestamp poll will be automatically closed, in milliseconds

    Returns null | number

  • get closedAt(): null | Date
  • Point in time when the poll will be automatically closed

    Returns null | Date

Methods

  • Protected

    Creates a clone of the current instance

    Returns Base

    A clone of the current instance

  • Parameters

    • data: Poll

      Data about the contains information about a poll

    Returns Poll

  • 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

  • Use this method to stop a poll which was sent by the bot. ONLY BOT POLL

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername).

    • messageId: string | number

      Identifier of the original message with the poll.

    • Optionaloptions: {
          businessConnectionId?: string;
          replyMarkup?: InlineKeyboardMarkup;
      }

      options for stopping poll

      • OptionalbusinessConnectionId?: string

        Unique identifier of the business connection on behalf of which the message to be edited was sent.

      • OptionalreplyMarkup?: InlineKeyboardMarkup

        An object for a new message inline keyboard.

    Returns Promise<Omit<Poll, "close">>

    On success, the stopped Poll is returned

  • 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