revbot.js
    Preparing search index...

    Class ClientUser

    Represents the client user, which is the authenticated user or bot.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new User instance.

      Parameters

      • client: client

        The client instance.

      • data: {
            _id: string;
            avatar?:
                | null
                | {
                    _id: string;
                    content_type: string;
                    deleted?: null
                    | boolean;
                    filename: string;
                    message_id?: null | string;
                    metadata:
                        | { type: "File" }
                        | { type: "Text" }
                        | { height: number; type: "Image"; width: number }
                        | { height: number; type: "Video"; width: number }
                        | { type: "Audio" };
                    object_id?: null | string;
                    reported?: null | boolean;
                    server_id?: null | string;
                    size: number;
                    tag: string;
                    user_id?: null | string;
                };
            badges?: number;
            bot?: null
            | { owner: string };
            discriminator: string;
            display_name?: null | string;
            flags?: number;
            online: boolean;
            privileged?: boolean;
            relations?: {
                _id: string;
                status:
                    | "User"
                    | "None"
                    | "Friend"
                    | "Outgoing"
                    | "Incoming"
                    | "Blocked"
                    | "BlockedOther";
            }[];
            relationship: | "User"
            | "None"
            | "Friend"
            | "Outgoing"
            | "Incoming"
            | "Blocked"
            | "BlockedOther";
            status?: | null
            | {
                presence?: null
                | "Online"
                | "Idle"
                | "Focus"
                | "Busy"
                | "Invisible";
                text?: null | string;
            };
            username: string;
        }

        The raw data for the user from the API.

        • _id: string

          Unique Id

        • Optionalavatar?:
              | null
              | {
                  _id: string;
                  content_type: string;
                  deleted?: null
                  | boolean;
                  filename: string;
                  message_id?: null | string;
                  metadata:
                      | { type: "File" }
                      | { type: "Text" }
                      | { height: number; type: "Image"; width: number }
                      | { height: number; type: "Video"; width: number }
                      | { type: "Audio" };
                  object_id?: null | string;
                  reported?: null | boolean;
                  server_id?: null | string;
                  size: number;
                  tag: string;
                  user_id?: null | string;
              }

          Avatar attachment

        • Optionalbadges?: number

          Format: uint32

        • Optionalbot?: null | { owner: string }

          Bot information

        • discriminator: string

          Discriminator

        • Optionaldisplay_name?: null | string

          Display name

        • Optionalflags?: number

          Format: uint32

        • online: boolean

          Whether this user is currently online

        • Optionalprivileged?: boolean

          Whether this user is privileged

        • Optionalrelations?: {
              _id: string;
              status:
                  | "User"
                  | "None"
                  | "Friend"
                  | "Outgoing"
                  | "Incoming"
                  | "Blocked"
                  | "BlockedOther";
          }[]

          Relationships with other users

        • relationship:
              | "User"
              | "None"
              | "Friend"
              | "Outgoing"
              | "Incoming"
              | "Blocked"
              | "BlockedOther"

          Current session user's relationship with this user

        • Optionalstatus?:
              | null
              | {
                  presence?: null
                  | "Online"
                  | "Idle"
                  | "Focus"
                  | "Busy"
                  | "Invisible";
                  text?: null | string;
              }

          User's current status

        • username: string

          Username

      Returns ClientUser

    Properties

    avatar: null | Attachment = null

    The avatar of the user, or null if none is set.

    badges: Badges

    The badges associated with the user.

    bot: boolean = false

    Whether the user is a bot.

    client: client

    The client instance.

    id: string

    The unique identifier for the object.

    notes: null | NotesChannel = null

    The notes channel associated with the client user, if any.

    presence: Presence = ...

    The presence status of the user.

    username: string

    The username of the user.

    Accessors

    • get createdTimestamp(): number

      Gets the creation timestamp of the user in milliseconds.

      Returns number

      The timestamp of when the user was created.

    Methods

    • Updates the object with new data and returns a clone of the object.

      Parameters

      • data: PartialObject

        The data to update the object with.

      • Optionalclear: string[]

        Fields to clear in the object.

      Returns this

      A clone of the updated object.

    • Updates the status of the client user.

      Parameters

      • text: null | string

        The status text to set, or null to clear the status.

      • Optionalpresence: Status

        The presence status (e.g., online, idle, etc.).

      Returns Promise<void>

      A promise that resolves when the status has been successfully updated.

      await clientUser.setStatus("Available", "online");
      
    • Updates the username of the client user.

      Parameters

      • username: string

        The new username to set.

      • Optionalpassword: string

        The current password of the user (required for non-bot accounts).

      Returns Promise<void>

      A promise that resolves when the username has been successfully updated.

      Throws an error if the client user is a bot and a password is provided.

      await clientUser.setUsername("NewUsername", "CurrentPassword");