assets
namespace assetsFunctions
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.
getAll(): UnboundAsset[]
Returns every asset, initializing every asset module first.
Returns
An array of all registered UnboundAsset records.
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.
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.
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.
onAssetRegistered(listener: AssetRegistrationListener): () => void
Calls listener with each asset registered from now on.
Returns
A function that removes the listener.
register(options: AssetRegistration): RegisteredAsset
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
assets: Map<number, UnboundAsset>
Map of registered asset ids to their UnboundAsset record.
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.