GramJS

messages.GetPollVotes

Get poll results for non-anonymous polls

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.messages.GetPollVotes({
      peer: "username",
      id: 43,
      limit: 100,
      option: Buffer.from("arbitrary data here"),
      offset: "some string here",
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.messages.VotesList = await client.invoke(
    new Api.messages.GetPollVotes({
      peer: "username",
      id: 43,
      limit: 100,
      option: Buffer.from("arbitrary data here"),
      offset: "some string here",
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
peerInputPeerChat where the poll was sent
idintMessage ID
optionflags.0?bytesGet only results for the specified poll option
offsetflags.1?stringOffset for results, taken from the next\_offset field of messages.votesList, initially an empty string.
Note: if no more results are available, the method call will return an empty next\_offset; thus, avoid providing the next\_offset returned in messages.votesList if it is empty, to avoid an infinite loop.
limitintNumber of results to return

Result

messages.VotesList

Possible errors

CodeTypeDescription
403BROADCAST_FORBIDDEN
400MSG_ID_INVALIDInvalid message ID provided
403POLL_VOTE_REQUIREDCast a vote in the poll before calling this method

Can bots use this method?

No

messages.votesList

How users voted in a poll