feat: show speaker nickname instead of raw user ID in voice logs
Resolve the Discord user ID to a server nickname / global name (cached) and display that in the transcript channel + console logs.
This commit is contained in:
@@ -38,6 +38,9 @@ export interface TurnInfo {
|
||||
/** Discord user ID of the speaker, so the transcript shows whose audio
|
||||
* produced each turn (and which user a dropped/VAD turn belongs to). */
|
||||
user?: string;
|
||||
/** Resolved display name (server nickname / global name); shown instead of
|
||||
* the raw user ID when available. */
|
||||
userName?: string;
|
||||
transcript: string;
|
||||
reply: string;
|
||||
note?: string;
|
||||
@@ -72,7 +75,7 @@ function durSec(a?: number, b?: number): string | null {
|
||||
* timing breakdown (listening / LLM / TTS) with start→end wall-clock times and
|
||||
* durations, so it's obvious what took long. Pure + exported for testing. */
|
||||
export function formatTurnMessage(info: TurnInfo): string {
|
||||
const who = info.user ? `👤 ${info.user} ` : "";
|
||||
const who = info.userName || info.user ? `👤 ${info.userName || info.user} ` : "";
|
||||
const head = info.transcript
|
||||
? `${who}🎤 들음 → 🗣️ "${info.transcript}"\n🤖 답변: ${(info.reply || "").trim() || "(무응답)"}`
|
||||
: `${who}🎤 들음 → ❌ ${info.note || "무시됨"}`;
|
||||
@@ -124,7 +127,7 @@ async function joinAndListen(client: AnyClient, channelId: string): Promise<void
|
||||
// joinVoiceChannel (it exposes id, guild.id and guild.voiceAdapterCreator).
|
||||
const session = await joinChannel(channel as unknown as VoiceBasedChannel);
|
||||
session.onTurn = (info) => {
|
||||
console.log(`👤 ${info.user || "?"} 🗣️ ${info.transcript || "(" + (info.note || "empty") + ")"}\n🤖 ${info.reply}`);
|
||||
console.log(`👤 ${info.userName || info.user || "?"} 🗣️ ${info.transcript || "(" + (info.note || "empty") + ")"}\n🤖 ${info.reply}`);
|
||||
// Mirror every heard utterance (and the reply / drop reason) to a text
|
||||
// channel so you can see what the bot understood even when it doesn't answer.
|
||||
void postTranscript(client, info);
|
||||
|
||||
Reference in New Issue
Block a user