GramJS

stickers.CreateStickerSet

Create a stickerset, bots only.

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.stickers.CreateStickerSet({
      userId: "username",
      title: "My very normal title",
      shortName: "some string here",
      stickers: [
        new Api.InputStickerSetItem({
          document: new Api.InputDocument({
            id: BigInt("-4156887774564"),
            accessHash: BigInt("-4156887774564"),
            fileReference: Buffer.from("arbitrary data here"),
          }),
          emoji: "some string here",
          maskCoords: new Api.MaskCoords({
            n: 43,
            x: 8.24,
            y: 8.24,
            zoom: 8.24,
          }),
        }),
      ],
      masks: true,
      animated: true,
      thumb: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data 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.StickerSet = await client.invoke(
    new Api.stickers.CreateStickerSet({
      userId: "username",
      title: "My very normal title",
      shortName: "some string here",
      stickers: [
        new Api.InputStickerSetItem({
          document: new Api.InputDocument({
            id: BigInt("-4156887774564"),
            accessHash: BigInt("-4156887774564"),
            fileReference: Buffer.from("arbitrary data here"),
          }),
          emoji: "some string here",
          maskCoords: new Api.MaskCoords({
            n: 43,
            x: 8.24,
            y: 8.24,
            zoom: 8.24,
          }),
        }),
      ],
      masks: true,
      animated: true,
      thumb: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data here"),
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
masksflags.0?trueWhether this is a mask stickerset
animatedflags.1?trueWhether this is an animated stickerset
userIdInputUserStickerset owner
titlestringStickerset name, 1-64 chars
shortNamestringSticker set name. Can contain only English letters, digits and underscores. Must end with "by" ( is case insensitive); 1-64 characters
thumbflags.2?InputDocumentThumbnail
stickersVector<InputStickerSetItem>Stickers

Result

messages.StickerSet

Possible errors

CodeTypeDescription
400BOT_MISSINGThis method can only be run by a bot
400PACK_SHORT_NAME_INVALIDShort pack name invalid
400PACK_SHORT_NAME_OCCUPIEDA stickerpack with this name already exists
400PACK_TITLE_INVALIDThe stickerpack title is invalid
400PEER_ID_INVALIDThe provided peer id is invalid
400SHORTNAME_OCCUPY_FAILEDAn internal error occurred
400STICKERS_EMPTYNo sticker provided
400STICKER_EMOJI_INVALIDSticker emoji invalid
400STICKER_FILE_INVALIDSticker file invalid
400STICKER_PNG_DIMENSIONSSticker png dimensions invalid
400STICKER_PNG_NOPNGOne of the specified stickers is not a valid PNG file
400USER_ID_INVALIDThe provided user ID is invalid

Can bots use this method?

Yes