banChatMember method

Future<bool> banChatMember(
  1. dynamic chatId,
  2. int userId, {
  3. int? untilDate,
  4. bool? revokeMessages,
})

Use this method to ban a user in a group, a supergroup or a channel

In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.

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

Implementation

Future<bool> banChatMember(dynamic chatId, int userId,
    {int? untilDate, bool? revokeMessages}) 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('banChatMember');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'user_id': userId,
    'until_date': untilDate,
    'revoke_messages': revokeMessages,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}