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,
      videos: true,
      thumb: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data here"),
      }),
      software: "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.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,
      videos: true,
      thumb: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data here"),
      }),
      software: "some string 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
videosflags.4?trueWhether this is a video 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
softwareflags.3?stringUsed when importing stickers using the sticker import SDKs, specifies the name of the software that created the 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.
400STICKERS_EMPTYNo sticker provided.
400STICKER_EMOJI_INVALIDSticker emoji invalid.
400STICKER_FILE_INVALIDSticker file invalid.
400STICKER_GIF_DIMENSIONSThe specified video sticker has invalid dimensions.
400STICKER_PNG_DIMENSIONSSticker png dimensions invalid.
400STICKER_PNG_NOPNGOne of the specified stickers is not a valid PNG file.
400STICKER_TGS_NODOCIncorrect document type for sticker.
400STICKER_TGS_NOTGSInvalid TGS sticker provided.
400STICKER_THUMB_PNG_NOPNGIncorrect stickerset thumb file provided, PNG / WEBP expected.
400STICKER_THUMB_TGS_NOTGSIncorrect stickerset TGS thumb file provided.
400STICKER_VIDEO_BIGThe specified video sticker is too big.
400STICKER_VIDEO_NOWEBMThe specified video sticker is not in webm format.
400USER_ID_INVALIDThe provided user ID is invalid.

Can bots use this method?

Yes