Skip to main content

What are assets?

Discord ships its images and icons as Metro modules, each one exporting a numeric id that the app resolves into an actual image. Components that render an icon want that id, but ids change between versions, so hardcoding one is fragile. assets solves this. At startup it indexes every bundled asset by name, so you can ask for 'ChatIcon' and get back the right id today, on this build.

Looking up assets

Each lookup is keyed by name and type (png or svg, defaulting to png).

The Icons proxy

For the common case (turning a name into an id), assets.Icons is the shortcut. Read any property off it and it resolves that name to its id on access.
Icons is just sugar over getIDByName. Use it when you want an id inline; use getByName when you need the full record (name, type, dimensions).