createForumTopic method

Future<ForumTopic> createForumTopic(
  1. dynamic chatId,
  2. String name, {
  3. int? iconColor,
  4. String? iconCustomEmojiId,
})

Use this method to create a topic in a forum supergroup chat.

The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.

Returns information about the created topic as a ForumTopic object.

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

Implementation

Future<ForumTopic> createForumTopic(dynamic chatId, String name,
    {int? iconColor, String? iconCustomEmojiId}) async {
  if (chatId is! String && chatId is! int) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('createForumTopic');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'name': name,
    'icon_color': iconColor,
    'icon_custom_emoji_id': iconCustomEmojiId,
  };
  return ForumTopic.fromJson(
      await HttpClient.httpPost(requestUrl, body: body));
}