The singleton collection of User documents which exist within the active World. This Collection is accessible within the Game object as game.users.

See

User The User document

Hierarchy (view full)

Properties

current: User

The User document of the currently connected user

apps: Application[]

An Array of application references which will be automatically updated when the collection content changes

invalidDocumentIds: Set<string> = ...

Record the set of document ids where the Document was not initialized because of invalid source data

documentName: string = "User"

Accessors

  • get players(): User[]
  • Get the users with player roles

    Returns User[]

  • get activeGM(): User
  • Get one User who is an active Gamemaster (non-assistant if possible), or null if no active GM is available. This can be useful for workflows which occur on all clients, but where only one user should take action.

    Returns User

  • get folders(): Collection<string, Folder>
  • Reference the set of Folders which contain documents in this collection

    Returns Collection<string, Folder>

  • get directory(): DocumentDirectory
  • Return a reference to the SidebarDirectory application for this WorldCollection.

    Returns DocumentDirectory

  • get documentClass(): typeof Document
  • A reference to the Document class definition which is contained within this DocumentCollection.

    Returns typeof Document

  • get documentName(): any
  • Returns any

    Inherit Doc

  • get name(): string
  • The Collection class name

    Returns string

  • get instance(): WorldCollection
  • Return a reference to the singleton instance of this WorldCollection, or null if it has not yet been created.

    Returns WorldCollection

  • get registeredSheets(): DocumentSheet[]
  • Return an array of currently registered sheet classes for this Document type.

    Returns DocumentSheet[]

    Static

Methods

  • Import a Document from a Compendium collection, adding it to the current World.

    Parameters

    • pack: CompendiumCollection

      The CompendiumCollection instance from which to import

    • id: string

      The ID of the compendium entry to import

    • Optional updateData: any = {}

      Optional additional data used to modify the imported Document before it is created

    • Optional options: any = {}

      Optional arguments passed to the WorldCollection#fromCompendium and Document.create methods

    Returns Promise<Document>

    The imported Document instance

  • Apply data transformations when importing a Document from a Compendium pack

    Parameters

    • document: any

      The source Document, or a plain data object

    • Optional options: FromCompendiumOptions = {}

      Additional options which modify how the document is imported

    Returns any

    The processed data ready for world Document creation

  • Instantiate a Document for inclusion in the Collection.

    Parameters

    • data: any

      The Document data.

    • Optional context: any = {}

      Document creation context.

    Returns Document

  • Obtain a temporary Document instance for a document id which currently has invalid source data.

    Parameters

    • id: string

      A document ID with invalid source data.

    • Optional options: {
          strict: boolean;
      } = {}

      Additional options to configure retrieval.

      • strict: boolean

        Throw an Error if the requested ID is not in the set of invalid IDs for this collection.

    Returns Document

    An in-memory instance for the invalid Document

    Throws

    If strict is true and the requested ID is not in the set of invalid IDs for this collection.

  • Get an element from the DocumentCollection by its ID.

    Parameters

    • id: string

      The ID of the Document to retrieve.

    • Optional options: {
          strict: boolean;
          invalid: boolean;
      } = {}

      Additional options to configure retrieval.

      • strict: boolean

        Throw an Error if the requested Document does not exist.

      • invalid: boolean

        Allow retrieving an invalid Document.

    Returns Document

    Throws

    If strict is true and the Document cannot be found.

  • Parameters

    • id: any
    • document: any

    Returns void

    Inherit Doc

  • Render any Applications associated with this DocumentCollection.

    Parameters

    • force: any
    • options: any

    Returns void

  • Find all Documents which match a given search term using a full-text search against their indexed HTML fields and their name. If filters are provided, results are filtered to only those that match the provided values.

    Parameters

    • search: {
          query: string;
          filters: FieldFilter[];
          exclude: string[];
      }

      An object configuring the search

      • query: string

        A case-insensitive search string

      • filters: FieldFilter[]

        An array of filters to apply

      • exclude: string[]

        An array of document IDs to exclude from search results

    Returns string[]

  • Update all objects in this DocumentCollection with a provided transformation. Conditionally filter to only apply to Entities which match a certain condition.

    Parameters

    • transformation: any

      An object of data or function to apply to all matched objects

    • condition: Function = null

      A function which tests whether to target each object

    • Optional options: any = {}

      Additional options passed to Document.updateDocuments

    Returns Promise<Document[]>

    An array of updated data once the operation is complete

  • Internal

    Follow-up actions to take when a database operation modifies Documents in this DocumentCollection.

    Parameters

    • action: DatabaseAction

      The database action performed

    • documents: ClientDocument[]

      The array of modified Documents

    • result: any[]

      The result of the database operation

    • operation: DatabaseOperation

      Database operation details

    • user: User

      The User who performed the operation

    Returns void

  • Private

    Initialize the Map object and all its contained documents

    Returns void

  • Register a Document sheet class as a candidate which can be used to display Documents of a given type. See DocumentSheetConfig.registerSheet for details.

    Parameters

    • Rest ...args: any[]

      Arguments forwarded to the DocumentSheetConfig.registerSheet method

    Returns void

    Static

    Example: Register a new ActorSheet subclass for use with certain Actor types.

    Actors.registerSheet("dnd5e", ActorSheet5eCharacter, { types: ["character], makeDefault: true });
    
  • Unregister a Document sheet class, removing it from the list of available sheet Applications to use. See DocumentSheetConfig.unregisterSheet for detauls.

    Parameters

    • Rest ...args: any[]

      Arguments forwarded to the DocumentSheetConfig.unregisterSheet method

    Returns void

    Static

    Example: Deregister the default ActorSheet subclass to replace it with others.

    Actors.unregisterSheet("core", ActorSheet);
    
  • Get the searchable fields for a given document or index, based on its data model

    Parameters

    • documentName: string

      The document type name

    • Optional documentSubtype: string = ""

      The document subtype name

    • Optional isEmbedded: boolean = false

      Whether the document is an embedded object

    Returns Set<string>

    The dot-delimited property paths of searchable fields

  • Private

    Handle receipt of activity data from another User connected to the Game session

    Parameters

    • userId: string

      The User id who generated the activity data

    • activityData: ActivityData = {}

      The object of activity data

    Returns void