From 735f94d1c8025b086bb6175ef1c1c3eff1d0f8a2 Mon Sep 17 00:00:00 2001 From: yuimarudev Date: Sat, 30 Nov 2024 21:25:29 +0900 Subject: [PATCH] refactor: remove inappropriate throw IIFE --- src/synthesizer/index.ts | 2 ++ src/voice/room.ts | 9 +-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/synthesizer/index.ts b/src/synthesizer/index.ts index c1b7791..0fe286e 100644 --- a/src/synthesizer/index.ts +++ b/src/synthesizer/index.ts @@ -50,6 +50,8 @@ export default class Synthesizer { }); if (!res.ok) throw new Error("読み上げに失敗しました"); + if (!res.body) + throw new Error("読み上げに失敗しました(body が帰ってきていません)"); return res.body; } diff --git a/src/voice/room.ts b/src/voice/room.ts index 3ac7b48..74e97d5 100644 --- a/src/voice/room.ts +++ b/src/voice/room.ts @@ -82,14 +82,7 @@ export default class Room { const resource = new AudioResource( [], - [ - Readable.fromWeb( - (await synthesizer.synthesis(content)) || - (() => { - throw "stream not found!"; - })(), - ), - ], + [Readable.fromWeb(await synthesizer.synthesis(content))], {}, 5, );