Guides

Stickers and Sticker Sets

Main Walkthrough 19 of 25

Clients can create, retrieve, and manage sticker sets.

Suggesting a SlugUSER-ONLY

suggestStickerSetSlug lets you generate a slug from a title.

const slug = await client.suggestStickerSetSlug("Cat Stickers");

Creating a Sticker Set

checkStickerSetSlug reports whether a slug is available. createStickerSet then accepts that slug with at least one sticker.

if (!await client.checkStickerSetSlug(slug)) {
  throw new Error("The sticker set slug is unavailable.");
}

const stickerSet = await client.createStickerSet(
  "Cat Stickers",
  slug,
  [{ sticker: "./cat.webp", emoji: "🐈" }],
);

Bot clients must pass { userId } as the final argument to identify the owner. User clients omit it.

Getting a Sticker Set

getStickerSet accepts a slug or sticker set link. getDiceStickerSet returns the set used by a dice emoji.

const stickerSet = await client.getStickerSet(slug);
const diceStickerSet = await client.getDiceStickerSet("🎲");

getCustomEmojiStickers returns stickers from their custom emoji identifiers.

Managing Stickers

addStickerToStickerSet lets you add an InputSticker or replaceStickerInStickerSet to replace an existing sticker.

await client.addStickerToStickerSet(
  slug,
  { sticker: "./sleeping-cat.webp", emoji: "😴" },
);

await client.replaceStickerInStickerSet(
  fileId,
  { sticker: "./new-cat.webp", emoji: "😺" },
);

Bot clients must pass { userId } as the final argument to both methods.

replaceStickerEmoji changes a sticker’s emoji, changeStickerPositionInStickerSet moves it, and removeStickerFromStickerSet removes it.

await client.replaceStickerEmoji(fileId, "😺");
await client.changeStickerPositionInStickerSet(fileId, 0);
await client.removeStickerFromStickerSet(fileId);

Changing Set Details

With setStickerSetTitle, you can change the title. Set the thumbnail with setStickerSetThumbnail or setCustomEmojiAsStickerSetThumbnail.

await client.setStickerSetTitle(slug, "Cat Reactions");
await client.setStickerSetThumbnail(slug, "./thumbnail.webp");
await client.setCustomEmojiAsStickerSetThumbnail(slug, customEmojiId);

Bot clients must pass { userId } to setStickerSetThumbnail.

Managing Added Sticker SetsUSER-ONLY

Users can add an existing set with addStickerSet and list added sets with getAddedStickerSets.

await client.addStickerSet(slug);
const stickerSets = await client.getAddedStickerSets();

archiveStickerSet and unarchiveStickerSet change whether an added set is archived. removeStickerSet removes it from the account.

await client.archiveStickerSet(slug);
await client.unarchiveStickerSet(slug);
await client.removeStickerSet(slug);

Managing Favorite StickersUSER-ONLY

Users can list favorite stickers with getFavoriteStickers.

const favoriteStickers = await client.getFavoriteStickers();

addStickerToFavorites and removeStickerFromFavorites with a sticker’s file identifier lets you update the list.

await client.addStickerToFavorites(sticker.fileId);
await client.removeStickerFromFavorites(sticker.fileId);

Managing Recent StickersUSER-ONLY

Users can list recent stickers with getRecentStickers.

const recentStickers = await client.getRecentStickers();

To update the list, call addStickerToRecents and removeStickerFromRecents with a sticker’s file identifier.

await client.addStickerToRecents(sticker.fileId);
await client.removeStickerFromRecents(sticker.fileId);

With clearRecentStickers, you can remove every sticker from the recent list.

await client.clearRecentStickers();

Deleting a Sticker Set

deleteStickerSet permanently deletes a sticker set.

await client.deleteStickerSet(slug);