Identifies who is speaking/acting and renders that voice to chat.

A SohlSpeaker resolves a loose set of identifiers (token, actor, scene, user ids, or an explicit alias) into the concrete documents an action needs, and knows how to emit chat messages attributed to that speaker. Every sohl.entity.action.SohlActionContext holds one as its speaker, so it is the backbone of action output: results, dialogs, and roll cards are all posted through a speaker.

Resolution rules applied at construction:

  • token is looked up on the active canvas; its actor becomes the speaker's actor when present;
  • actor is resolved directly only if a token did not already supply one;
  • user defaults to the current user when not given;
  • rollMode defaults to the core rollMode setting, then to the system default;
  • name is the first available of: explicit alias, token name, actor name, the user's assigned character name, the user name, or "Unknown Speaker".

Use toChat to post a message — it accepts either inline HTML or a template path and applies the speaker's roll mode automatically.

Constructors

  • Construct a SohlSpeaker instance, resolving the token, actor, scene, user and display name from the supplied ids.

    Parameters

    • data: Partial<sohl.core.logic.SohlSpeaker.Data> = {}

      Speaker source data.

      • rollMode

        The roll mode to use.

      • user

        The user ID.

      • token

        The token ID; requires an initialized canvas.

      • actor

        The actor ID; used only when no token is provided.

      • scene

        The scene ID.

      • alias

        The explicit display name, overriding all resolved names.

    Returns sohl.core.logic.SohlSpeaker

    If data.token is set but the Foundry canvas is not yet initialized.

Properties

actorLogic?: SohlActorLogic<any>

The resolved actor (from the token or directly), or null.

name: string

The display name/alias used for attribution.

rollMode: string

The roll mode applied to messages this speaker posts.

sceneId?: string

The resolved scene, or null.

The resolved token, or null.

userId?: string

The resolved user (defaults to the current user), or null.

Accessors

Methods

  • Post a chat message attributed to this speaker.

    The input is dispatched by type: a FilePath is rendered as a Handlebars template, while an HTMLString is used as inline content. The speaker's roll mode is applied automatically.

    Parameters

    • input: HTMLString | FilePath

      A template path or inline HTML content.

    • Optionaldata: PlainObject

      Template context data — forwarded to the template or content renderer without property access.

    • Optionaloptions: PlainObject

      Chat options; see SohlSpeaker.ChatOptions for supported fields.

    Returns Promise<undefined | ChatMessage>

    The created ChatMessage, or undefined if none was created.

  • Serialize to a plain object of resolved ids plus alias and roll mode.

    Returns JsonValue

    The plain-object representation of this speaker.