Fetcher
Fetcher is a cache-first REST wrapper available on every interaction object as interaction.fetcher. It checks the CacheManager before making a live Discord API request, and writes the result back to the cache automatically.
// Inside any handler or middlewareconst user = await interaction.fetcher.users.get(userId);If no cache adapter is configured, Fetcher bypasses the cache and always fetches from the API.
Constructor
Section titled “Constructor”Fetcher is instantiated internally by BaseInteraction — you do not construct it directly.
Public properties
Section titled “Public properties”api: API (readonly)
Section titled “api: API (readonly)”The raw @discordjs/core API instance. Use this for any Discord REST call not covered by the named accessors.
await interaction.fetcher.api.stickers.get(stickerId);Namespaced accessors
Section titled “Namespaced accessors”get(userId: string): Promise<APIUser>
Section titled “get(userId: string): Promise<APIUser>”Fetches a user by ID. Returns the cached value if available, otherwise fetches from Discord and caches the result.
channels
Section titled “channels”get(channelId: string): Promise<CachedChannel>
Section titled “get(channelId: string): Promise<CachedChannel>”Fetches a channel by ID. Returns the cached value if available, otherwise fetches from Discord and caches the result.
guilds
Section titled “guilds”get(guildId: string): Promise<APIGuild>
Section titled “get(guildId: string): Promise<APIGuild>”Fetches a guild by ID. Returns the cached value if available, otherwise fetches from Discord and caches the result.
get(guildId: string, roleId: string): Promise<APIRole>
Section titled “get(guildId: string, roleId: string): Promise<APIRole>”Fetches a single role. If not cached, fetches all roles for the guild via guilds.getRoles and returns the matching one.
list(guildId: string): Promise<APIRole[]>
Section titled “list(guildId: string): Promise<APIRole[]>”Fetches all roles for a guild. Returns cached roles if available (via CacheManager.getGuildRoles), otherwise fetches from Discord and bulk-caches the result.
members
Section titled “members”get(guildId: string, userId: string): Promise<APIGuildMember | CachedGuildMember>
Section titled “get(guildId: string, userId: string): Promise<APIGuildMember | CachedGuildMember>”Fetches a guild member by user ID. Returns the cached value if available, otherwise fetches from Discord and caches the result.