createNewStickerSet method

Future<bool> createNewStickerSet(
  1. int userId,
  2. String name,
  3. String title,
  4. List<InputSticker> stickers,
  5. String stickerFormat, {
  6. String? stickerType,
  7. bool? needsRepainting,
})

Use this method to create sticker set owned by a user

The bot will be able to edit the created sticker set. You must use exactly one of the fields pngSticker, tgsSticker, or webmSticker.

Returns True on success.

https://core.telegram.org/bots/api#createnewstickerset

Implementation

Future<bool> createNewStickerSet(int userId, String name, String title,
    List<InputSticker> stickers, String stickerFormat,
    {String? stickerType, bool? needsRepainting}) async {
  var requestUrl = _apiUri('createNewStickerSet');
  var botInfo = await getMe();
  var body = <String, dynamic>{
    'user_id': userId,
    'name': '${name}_by_${botInfo.username}',
    'title': title,
    'stickers': jsonEncode(stickers),
    'sticker_format': stickerFormat,
    'sticker_type': stickerType,
    'needs_repainting': needsRepainting,
  };

  List<MultipartFile> stickerFiles = stickers
      .map((it) => it.stickerFile)
      .whereType<MultipartFile>()
      .toList();

  if (stickerFiles.isNotEmpty) {
    return await HttpClient.httpMultipartPost(requestUrl, stickerFiles,
        body: body);
  } else {
    return await HttpClient.httpPost(requestUrl, body: body);
  }
}