N

assets

namespace assets

Functions

F

find(filter: (asset: UnboundAsset) => boolean): UnboundAsset | undefined

Finds the first asset matching the given predicate, initializing every asset module first.

Returns

The matched UnboundAsset, or undefined if none match.

Returns every asset, initializing every asset module first.

Returns

An array of all registered UnboundAsset records.

F

getById(id: number): UnboundAsset | undefined

Looks up a registered asset by its id.

Returns

The matched UnboundAsset, or undefined if none is registered for that id.

F

getByName<T extends AssetType = "png">(name: AssetName<T>, type?: T): UnboundAsset | undefined

Finds an asset by its name and type, initializing the module that registers it if needed.

Returns

The matched UnboundAsset, or undefined if none match.

F

getIdByName<T extends AssetType = "png">(name: AssetName<T>, type?: T): number | undefined

Looks up an asset's id by its name and type, initializing the module that registers it if needed.

Returns

The matched asset's id, or undefined if none match.

Calls listener with each asset registered from now on.

Returns

A function that removes the listener.

Registers an image generated at runtime, such as a data: URI or a file the plugin wrote, with Discord's asset registry, so <Image source={id}> and Discord's icon props draw it. Images a plugin imports are registered for it. A plugin's names never collide with another's, and its registrations end when it stops.

Returns

The asset's id, and unregister.

Types

An image to register with Discord's asset registry, so <Image source={id}> and Discord's icon props draw it.

Called with each asset Discord registers, and its id.

A registered asset: its id, and the function that takes it out of the registry.

An asset name of file type T: the names Discord's generated build registers as suggestions, and any other string, since a build may register names the generator never saw.

A file type the asset lookups take: Discord's types as suggestions, and any other string.

The name of an asset Discord registers, of the given file types.

A DiscordAsset extended with Unbound's icon-pack overrides and the files of an asset a plugin registered.

Variables

V

assets: Map<number, UnboundAsset>

Map of registered asset ids to their UnboundAsset record.

V

icons: Readonly<Partial<Record<DiscordAssetName<"png">, number>>> & Readonly<Record<string, number | undefined>>

Proxy resolving any property name to its PNG asset id via getIdByName; Discord's names are suggested.