createChatInviteLink method

Future<ChatInviteLink> createChatInviteLink(
  1. dynamic chat_id, {
  2. int? expire_date,
  3. int? member_limit,
})
inherited

Use this method to create an additional invite link for a chat

The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method revokeChatInviteLink.

Returns the new invite link as ChatInviteLink object.

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

Implementation

Future<ChatInviteLink> createChatInviteLink(dynamic chat_id,
    {int? expire_date, int? member_limit}) 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('createChatInviteLink');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'expire_date': expire_date,
    'member_limit': member_limit,
  };
  return ChatInviteLink.fromJson(
      await HttpClient.httpPost(requestUrl, body: body));
}