promoteChatMember method

Future<bool> promoteChatMember(
  1. dynamic chatId,
  2. int userId, {
  3. bool? isAnonymous,
  4. bool? canManageChat,
  5. bool? canPostMessages,
  6. bool? canEditMessages,
  7. bool? canDeleteMessages,
  8. bool? canManageVideoChats,
  9. bool? canRestrictMembers,
  10. bool? canPromoteMembers,
  11. bool? canChangeInfo,
  12. bool? canInviteUsers,
  13. bool? canPinMessages,
  14. bool? canManageTopics,
})

Use this method to promote or demote a user in a supergroup or a channel

The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success.

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

Implementation

Future<bool> promoteChatMember(dynamic chatId, int userId,
    {bool? isAnonymous,
    bool? canManageChat,
    bool? canPostMessages,
    bool? canEditMessages,
    bool? canDeleteMessages,
    bool? canManageVideoChats,
    bool? canRestrictMembers,
    bool? canPromoteMembers,
    bool? canChangeInfo,
    bool? canInviteUsers,
    bool? canPinMessages,
    bool? canManageTopics}) 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('promoteChatMember');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'user_id': userId,
    'is_anonymous': isAnonymous,
    'can_manage_chat': canManageChat,
    'can_post_messages': canPostMessages,
    'can_edit_messages': canEditMessages,
    'can_delete_messages': canDeleteMessages,
    'can_manage_video_chats': canManageVideoChats,
    'can_restrict_members': canRestrictMembers,
    'can_promote_members': canPromoteMembers,
    'can_change_info': canChangeInfo,
    'can_invite_users': canInviteUsers,
    'can_pin_messages': canPinMessages,
    'can_manage_topics': canManageTopics,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}