diff --git a/src/commands/config.rs b/src/commands/config.rs index 737ce33..11a5a2b 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -44,55 +44,65 @@ pub async fn config_command( f.interaction_response_data(|d| { d.content("読み上げ設定") .components(|c| { - c.create_action_row(|a| { - a.create_select_menu(|m| { - m.custom_id("TTS_CONFIG_ENGINE") - .options(|o| { - o.create_option(|co| { - co.label("Google TTS") - .value("TTS_CONFIG_ENGINE_SELECTED_GOOGLE") - .default_selection(tts_type == TTSType::GCP) - }) - .create_option( - |co| { + let mut c = c; + c = c + .create_action_row(|a| { + a.create_select_menu(|m| { + m.custom_id("TTS_CONFIG_ENGINE") + .options(|o| { + o.create_option(|co| { + co.label("Google TTS") + .value("TTS_CONFIG_ENGINE_SELECTED_GOOGLE") + .default_selection(tts_type == TTSType::GCP) + }) + .create_option(|co| { co.label("VOICEVOX") .value("TTS_CONFIG_ENGINE_SELECTED_VOICEVOX") .default_selection( tts_type == TTSType::VOICEVOX, ) - }, - ) - }) - .placeholder("読み上げAPIを選択") + }) + }) + .placeholder("読み上げAPIを選択") + }) }) - }) - .create_action_row(|a| { - a.create_select_menu(|m| { - m.custom_id("TTS_CONFIG_VOICEVOX_SPEAKER") + .create_action_row(|a| { + a.create_button(|f| { + f.label("サーバー設定") + .custom_id("TTS_CONFIG_SERVER") + .style(ButtonStyle::Primary) + }) + }); + + for (index, speaker_chunk) in voicevox_speakers.chunks(25).enumerate() { + c = c.create_action_row(|a| { + let mut a = a; + a = a.create_select_menu(|m| { + m.custom_id( + "TTS_CONFIG_VOICEVOX_SPEAKER_".to_string() + + &index.to_string(), + ) .options(|o| { let mut o = o; - for (name, value) in voicevox_speakers { + for (name, id) in speaker_chunk { o = o.create_option(|co| { co.label(name) .value(format!( "TTS_CONFIG_VOICEVOX_SPEAKER_SELECTED_{}", - value + id )) - .default_selection(value == voicevox_speaker) + .default_selection(*id == voicevox_speaker) }) } o }) .placeholder("VOICEVOX Speakerを指定") + }); + a }) - }) - .create_action_row(|a| { - a.create_button(|f| { - f.label("サーバー設定") - .custom_id("TTS_CONFIG_SERVER") - .style(ButtonStyle::Primary) - }) - }) + } + + c }) .flags(MessageFlags::EPHEMERAL) })