Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MessageBot

Hierarchy

  • MessageBot

Index

Constructors

constructor

  • Parameters

    • storage: Storage

      The storage instance to be used by the bot.

    • info: WorldInfo

      The world info that is used to create the API to interact with the world.

    Returns MessageBot

Properties

storage

storage: Storage

The storage instance to be used by the bot.

world

world: World

The world that the bot is loaded on.

Static dependencies

dependencies: object

External dependencies that must be set before creating any instances of this class.

Type declaration

Static extensionDeregistered

extensionDeregistered: SafeSimpleEvent<string> = extensionDeregistered.asEvent()

An event that fires when an extension is deregistered, if it has been registered. Will not fire when an extension is re-registered.

Static extensionRegistered

extensionRegistered: SafeSimpleEvent<string> = extensionRegistered.asEvent()

An event that fires whenever an extension is registered or re-registered.

Accessors

extensions

  • get extensions(): string[]
  • An array of currently loaded extension ids

    Returns string[]

fetch

  • get fetch(): fetch
  • Shortcut for MessageBot.dependencies.fetch

    Returns fetch

Static extensions

  • get extensions(): string[]
  • An array of all registered extensions.

    Returns string[]

Methods

addExtension

  • addExtension(id: string): void
  • Adds an extension to this bot. Calls the init function supplied when registering the extension.

    Parameters

    • id: string

      the id of the registered extension to add.

    Returns void

getExports

  • getExports(id: string): object | undefined
  • Gets the exports of an extension, returns undefined if the extension is not loaded.

    Parameters

    • id: string

      the extension id to get exports from

    Returns object | undefined

removeExtension

  • removeExtension(id: string, uninstall: boolean): void
  • Removes a currently loaded extension. Should not be used by published extensions unless the extension is an extension manager.

    Parameters

    • id: string

      the id of the extension to remove

    • uninstall: boolean

      whether or not the extension should be completely removed, or just unloaded.

    Returns void

send

  • send(message: string, __namedParameters?: object): void
  • Sends a message to the world for this bot, should usually be used in place of world.send.

    Parameters

    • message: string

      the message to send

    • Default value __namedParameters: object = {}

    Returns void

start

  • start(): void
  • Starts listening to chat.

    Returns void

Static deregisterExtension

  • deregisterExtension(id: string): void
  • Removes an extension initializer from the registry, can be used to prevent an extension from being loaded in multiple bots at once (generally a bad idea).

    Parameters

    • id: string

      the id of the extension to deregister

    Returns void

Static registerExtension

  • Registers an extension that can be loaded by instances of the bot. Note: If an extension has already been loaded from a previously registered initializer, it will not be overwritten.

    Parameters

    • id: string

      the extension ID, will be normalized to lower case.

    • initializer: ExtensionInitializer

      the function to be called to set up the extension.

    Returns void

Generated using TypeDoc