setChatTitle method

Future<bool> setChatTitle(
  1. dynamic chatId,
  2. String title
)

Use this method to change the title of a chat

Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

Returns True on success.

Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.

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

Implementation

Future<bool> setChatTitle(dynamic chatId, String title) 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('setChatTitle');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'title': title,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}