Hoshimi
Guides

Search and Sources

Query tracks safely with manager/player search and source selection.

This guide documents how search works in the real API surface. Use it to choose sources intentionally and branch correctly by load type.

Type reference: Core API (TypeDoc)

Quick links:

Search from Manager

Use manager search when you want to resolve results before creating/using a player.

manager-search.ts
import {  } from 'hoshimi';
import type {  } from 'hoshimi';

declare const : ;

const  = await .({
  : 'Daft Punk - Harder Better Faster Stronger',
  : .,
  : {
    : '123',
    : 'demo-user',
  },
});

.(.);
.(..);

Search from Player

Use player search in command handlers where the player already exists.

player-search.ts
import {  } from 'hoshimi';
import type {  } from 'hoshimi';

declare const : ;

const  = await .({
  : 'Lofi hip hop',
  : {
    : '123',
    : 'demo-user',
  },
});

if (. === . || . === .) {
  await ..(.[0]);

  if (!.()) {
    await .();
  }
}

Source Strategy

  • Set a default source in manager options (defaultSearchSource).
  • Override per query with source in SearchOptions when needed.
  • Always branch by loadType (Track, Search, Playlist, Empty, Error).

On this page