banChatMember method

Future<bool> banChatMember(
  1. dynamic chat_id,
  2. int user_id, {
  3. int? until_date,
  4. bool? revoke_messages,
})
inherited

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 chat_id, int user_id,
    {int? until_date, bool? revoke_messages}) async {
  if (chat_id is! String && chat_id is! int) {
    return Future.error(TelegramException(
        'Attribute \'chat_id\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('banChatMember');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'user_id': user_id,
    'until_date': until_date,
    'revoke_messages': revoke_messages,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}