createNewStickerSet method

Future<bool> createNewStickerSet({
  1. required int userId,
  2. required String name,
  3. required String title,
  4. required List<InputSticker> stickers,
  5. StickerType stickerType = StickerType.regular,
  6. bool needsRepainting = false,
})

Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.

Parameters:

  • userId - User identifier of created sticker set owner
  • name - Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "by<bot_username>". <bot_username> is case insensitive. 1-64 characters.
  • title - Sticker set title, 1-64 characters
  • stickers - List of stickers to be added to the set
  • stickerType - Sticker type
  • needsRepainting - Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only

Implementation

Future<bool> createNewStickerSet({
  required int userId,
  required String name,
  required String title,
  required List<InputSticker> stickers,
  StickerType stickerType = StickerType.regular,
  bool needsRepainting = false,
}) async {
  Map<String, dynamic> params = {
    "user_id": userId,
    "name": name,
    "title": title,
    "sticker_type": stickerType.type,
    "needs_repainting": needsRepainting,
  };
  bool response;
  List<Map<String, dynamic>> stickersList = [];
  List<_MultipartHelper> helpers = [];

  final length = stickers.length;
  for (int i = 0; i < length; i++) {
    stickersList.add(stickers[i].toJson("sticker$i"));
    helpers.add(_MultipartHelper(stickers[i].sticker, "sticker$i"));
  }

  final files = _getFiles(helpers);
  params["stickers"] = stickersList;

  if (files.isNotEmpty) {
    response = await _httpClient.multipartPost(
      _buildUri(APIMethod.createNewStickerSet),
      files,
      params,
    );
  } else {
    response = await _httpClient.postURI(
      _buildUri(APIMethod.createNewStickerSet),
      params,
    );
  }

  return response;
}