telegramsjs
    Preparing search index...

    Class User

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    firstName: string

    User's or bot's first name

    id: string

    Unique identifier for this user or bot.

    inAttachmentMenu?: boolean

    True, if this user added the bot to the attachment menu

    isBot: boolean

    True, if this user is a bot

    isPremium?: boolean

    True, if this user is a Telegram Premium user

    language?: LanguageCode

    IETF language tag of the user's language

    lastName?: string

    User's or bot's last name

    username?: string

    User's or bot's username

    Accessors

    Methods

    • Protected

      Creates a clone of the current instance

      Returns Base

      A clone of the current instance

    • Parameters

      • data: User | UserFromGetMe

        represents a Telegram user or bot

      Returns User | UserFromGetMe

    • Protected

      Updates the current instance with new data and returns a clone of the updated instance

      Parameters

      • data: Record<string, any>

        The data to update the instance with

      Returns Base

      A clone of the updated instance

    • Checks if this user is equal to another user.

      Parameters

      Returns boolean

      True if both objects are instances of User and are equal based on key properties, otherwise false.

    • Fetches this user

      Parameters

      • Optionaloptions: Omit<IFetchOptions, "cache" | "fullInfo"> & { fullInfo?: false }

        options for fetch user

      Returns Promise<User>

    • Fetches this user

      Parameters

      • Optionaloptions: Omit<IFetchOptions, "cache" | "fullInfo"> & { fullInfo: true }

        options for fetch user

      Returns Promise<ChatFullInfo>

    • Fetches this user

      Parameters

      • Optionaloptions: Omit<IFetchOptions, "cache">

        options for fetch user

      Returns Promise<ChatFullInfo | User>

    • Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat.

      Parameters

      • chatId: string | number

        Unique identifier for the chat or username of the channel (in the format @channelusername).

      Returns Promise<UserChatBoosts>

      Returns a UserChatBoosts object.

    • Use this method to get a list of profile pictures for a user.

      Parameters

      • Optionaloffset: number

        Sequential number of the first photo to be returned. By default, all photos are returned

      • Optionallimit: number

        Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100

      Returns Promise<UserProfilePhotos>

      Returns a UserProfilePhotos object.

    • Gifts a Telegram Premium subscription to the given user.

      Parameters

      • monthCount: 3 | 6 | 12

        Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12.

      • starCount: 1000 | 1500 | 2500

        Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months.

      • Optionaloptions: Omit<
            {
                monthCount: 3
                | 6
                | 12;
                starCount: 1000 | 1500 | 2500;
                text?: string;
                textEntities?: MessageEntity[];
                textParseMode?: ParseMode;
                userId: string | number;
            },
            "userId"
            | "monthCount"
            | "starCount",
        >

        out parameters.

      Returns Promise<true>

      Returns True on success.

    • Refunds a successful payment in Telegram Stars.

      Parameters

      • telegramPaymentId: string

        Telegram payment identifier

      Returns Promise<true>

      Returns True on success.

    • Removes verification from a user who is currently verified on behalf of the organization represented by the bot.

      Returns Promise<true>

      Returns True on success.

    • Stores a message that can be sent by a user of a Mini App.

      Parameters

      • result: InlineQueryResult

        An object describing the message to be sent.

      • Optionaloptions: Omit<
            {
                allowBotChats?: boolean;
                allowChannelChats?: boolean;
                allowGroupChats?: boolean;
                allowUserChats?: boolean;
                result: InlineQueryResult;
                userId: string
                | number;
            },
            "userId"
            | "result",
        >

        out parameters.

      Returns Promise<PreparedInlineMessage>

      Returns a PreparedInlineMessage object.

    • Use this method to send text messages.

      Parameters

      • text: string

        Text of the message to be sent, 1-4096 characters after entities parsing and media group options

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId: string
                | number;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                entities?: MessageEntity[];
                linkPreviewOptions?: LinkPreviewOptions;
                messageEffectId?: string;
                messageThreadId?: string | number;
                parseMode?: ParseMode;
                protectContent?: boolean;
                replyMarkup?:
                    | InlineKeyboardMarkup
                    | ForceReply
                    | ReplyKeyboardMarkup
                    | ReplyKeyboardRemove;
                replyParameters?: ReplyParameters;
                suggestedPostParameters?: SuggestedPostParameters;
                text: string;
            },
            "text"
            | "chatId",
        >

        out parameters

      Returns Promise<Message & { content: string }>

      On success, the sent Message is returned.

    • Use this method to send text messages.

      Parameters

      • text: Omit<
            {
                businessConnectionId?: string;
                chatId: number
                | string;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                media: ReadonlyArray<
                    | InputMediaAudio
                    | InputMediaDocument
                    | InputMediaPhoto
                    | InputMediaVideo,
                >;
                messageEffectId?: string;
                messageThreadId?: string
                | number;
                protectContent?: boolean;
                replyParameters?: ReplyParameters;
                suggestedPostParameters?: SuggestedPostParameters;
            },
            "chatId",
        >

        Text of the message to be sent, 1-4096 characters after entities parsing and media group options

      Returns Promise<
          (
              | Message & { audio: Audio }
              | Message & { document: Document }
              | Message & { photo: Photo }
              | Message & { video: Video }
          )[],
      >

      On success, the sent Message is returned.

    • Use this method to send text messages.

      Parameters

      • text:
            | string
            | Omit<
                {
                    businessConnectionId?: string;
                    chatId: string
                    | number;
                    directMessagesTopicId?: number;
                    disableNotification?: boolean;
                    media: readonly (
                        | InputMediaAudio
                        | InputMediaDocument
                        | InputMediaPhoto
                        | InputMediaVideo
                    )[];
                    messageEffectId?: string;
                    messageThreadId?: string
                    | number;
                    protectContent?: boolean;
                    replyParameters?: ReplyParameters;
                    suggestedPostParameters?: SuggestedPostParameters;
                },
                "chatId",
            >

        Text of the message to be sent, 1-4096 characters after entities parsing and media group options

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId: string
                | number;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                entities?: MessageEntity[];
                linkPreviewOptions?: LinkPreviewOptions;
                messageEffectId?: string;
                messageThreadId?: string | number;
                parseMode?: ParseMode;
                protectContent?: boolean;
                replyMarkup?:
                    | InlineKeyboardMarkup
                    | ForceReply
                    | ReplyKeyboardMarkup
                    | ReplyKeyboardRemove;
                replyParameters?: ReplyParameters;
                suggestedPostParameters?: SuggestedPostParameters;
                text: string;
            },
            "text"
            | "chatId",
        >

        out parameters

      Returns Promise<
          | Message & { content: string }
          | (
              | Message & { audio: Audio }
              | Message & { document: Document }
              | Message & { photo: Photo }
              | Message & { video: Video }
          )[],
      >

      On success, the sent Message is returned.

    • Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receive.

      Parameters

      • giftId: string

        Identifier of the gift.

      • Optionaloptions: Omit<
            {
                chatId?: string
                | number;
                giftId: string;
                payForUpgrade?: boolean;
                text?: string;
                textEntities?: MessageEntity[];
                textParseMode?: ParseMode;
                userId?: string | number;
            },
            "giftId"
            | "userId",
        >

        out parameters.

      Returns Promise<true>

      Returns True on success.

    • Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess.

      Parameters

      • Optionaloptions: { emojiStatusCustomEmojiId?: string; emojiStatusExpirationDate?: number }

        out parameters.

        • OptionalemojiStatusCustomEmojiId?: string

          Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.

        • OptionalemojiStatusExpirationDate?: number

          Expiration date of the emoji status, if any

      Returns Promise<true>

      Returns True on success.

    • Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change).

      Parameters

      Returns Promise<true>

      Returns True on success.

    • Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars.

      Parameters

      • telegramPaymentChargeId: string

        Telegram payment identifier for the subscription.

      • isCanceled: boolean

        Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.

      Returns Promise<true>

      Returns True on success.

    • Flatten an object. Any properties that are collections will get converted to an array of keys.

      Parameters

      • OptionalpropsRecursive: boolean

        Optional. If true, calls toJSON method on nested objects.

      • ...props: Record<string, string | boolean>[]

        Optional. Specific properties to include/exclude, or rename.

      Returns Record<string, any>

      Flattened object.

    • Returns the id instance Chat, User, ChatMember and other

      Returns string | null

    • Verifies a user on behalf of the organization which is represented by the bot.

      Parameters

      • Optionaldescription: string

        Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.

      Returns Promise<true>

      Returns True on success.