feat(voice): per-user TTS voice selection via /목소리
Until now every TTS message was synthesized with VoiceType.가람
regardless of who spoke. This adds a user-scoped voice preference
persisted in SQLite so each member can pick their own voice and
keep it across bot restarts.
Changes
- db/schema.sql: add nullable `voice_type` column to `users`.
- src/utils/Database.ts:
- run a PRAGMA-driven ALTER TABLE migration so existing DBs gain
the column without dropping data.
- add `DB.user.setVoice(guildId, userId, name, voiceType)` that
upserts the row.
- src/classes/TTSClient.ts:
- export `DEFAULT_VOICE` (= 가람).
- resolve the speaking member's stored voice in `tts()` and
thread it through `getSource()` instead of hardcoding 가람.
- validate stored slug against `VoiceType` so stale/unknown
values silently fall back to the default.
- src/commands/voice.ts (new):
- `/목소리` slash command shows the user's current voice and a
StringSelectMenu of all `VoiceType` entries (현재 + 이전 보이스
모두). Selection writes to `users.voice_type` and confirms
ephemerally.
- defensively creates a guild row if `/tts channel register`
hasn't run yet, to satisfy the ON DELETE CASCADE FK.
Deploy
Run `npm run prod` after pulling so Discord sees the new
`/목소리` command. No env or config changes required.
This commit is contained in:
@@ -9,9 +9,10 @@ CREATE TABLE IF NOT EXISTS guilds (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
guild_id TEXT NOT NULL, -- 소속 길드 ID, guilds.id를 참조
|
||||
id TEXT NOT NULL, -- 유저 ID
|
||||
name TEXT NOT NULL, -- 유저 이름 (캐싱용)
|
||||
guild_id TEXT NOT NULL, -- 소속 길드 ID, guilds.id를 참조
|
||||
id TEXT NOT NULL, -- 유저 ID
|
||||
name TEXT NOT NULL, -- 유저 이름 (캐싱용)
|
||||
voice_type TEXT, -- TTS 목소리 슬러그 (NULL = 기본)
|
||||
|
||||
-- 복합 기본키: 같은 길드 안에서 id는 중복 불가
|
||||
PRIMARY KEY (guild_id, id),
|
||||
|
||||
Reference in New Issue
Block a user