promoteChatMember method
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,
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.
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);
}