Skip to content

Commit

Permalink
fix action row
Browse files Browse the repository at this point in the history
  • Loading branch information
mii443 committed Oct 3, 2023
1 parent c39800d commit 0fbe068
Showing 1 changed file with 40 additions and 30 deletions.
70 changes: 40 additions & 30 deletions src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 0fbe068

Please sign in to comment.