tools.stop_music module
Stop the active Lyria music stream and disconnect from voice.
Defines the stop_music tool, which the LLM uses to end a generative
Lyria music session in a Discord guild and leave the voice channel. The
real work is delegated to the adapter’s lyria_service; this module is
only the tool shell (metadata plus the run handler).
- async tools.stop_music.run(guild_id, ctx=None)[source]
Stop the guild’s active Lyria stream and disconnect the bot from voice.
The
stop_musictool entry point. It validates that a Discord adapter is present and that a real Discord client is reachable, parses the guild id, and then hands off to the Lyria service to halt playback and leave the voice channel. It only runs on the Discord platform.Resolves the client via
get_discord_client(fromtools._discord_helpers) and readsctx.adapter.lyria_service, then awaits itsstopcoroutine, which cancels the streaming task, drops the cached session state, and force-disconnects the voice client for that guild. No Redis, knowledge graph, or LLM interaction occurs here. As a tool it is dispatched by name through the registry —tool_loader.pyregisters this module’srunas the handler forstop_musicand the inference worker invokes it on the matching tool call; it has no in-repo direct callers.- Parameters:
guild_id (
str) – The Discord guild (server) id whose music session to stop, as a string; it is parsed tointbefore being passed to the Lyria service.ctx (
ToolContext|None) – The tool context supplyingadapter(and thus the Discord client andlyria_service).
- Returns:
The Lyria service’s result string (e.g.
"Stopped"or a “music is not currently playing” message), or an error string when the adapter or Discord client is unavailable orguild_idis not a valid integer.- Return type: