@@ -24,18 +24,14 @@ int main() {
2424 .set_text_style (dpp::text_short)
2525 );
2626
27- /* Add another text component in the next row, as required by Discord */
28- modal.add_row ();
27+ /* Add a channel selection */
2928 modal.add_component (
3029 dpp::component ()
31- .set_label (" Type rammel" )
32- .set_id (" field_id2" )
33- .set_type (dpp::cot_text)
34- .set_placeholder (" gumf" )
35- .set_min_length (1 )
36- .set_max_length (2000 )
37- .set_text_style (dpp::text_paragraph)
30+ .set_label (" Select channel" )
31+ .set_id (" field_id2" )
32+ .set_type (dpp::cot_channel_selectmenu)
3833 );
34+
3935
4036 /* Trigger the dialog box. All dialog boxes are ephemeral */
4137 event.dialog (modal);
@@ -44,13 +40,19 @@ int main() {
4440
4541 /* This event handles form submission for the modal dialog we create above */
4642 bot.on_form_submit ([](const dpp::form_submit_t & event) {
47- /* For this simple example, we know the first element of the first row ([0][0]) is value type string.
43+ /* For this simple example, we know the elements value type is string.
44+ * We also know the indices of each element.
4845 * In the real world, it may not be safe to make such assumptions!
4946 */
50- std::string v = std::get<std::string>(event.components [0 ].components [0 ].value );
47+ std::string message_text = std::get<std::string>(event.components [0 ].value );
48+ std::string channel_id = std::get<std::string>(event.components [1 ].value );
5149
5250 dpp::message m;
53- m.set_content (" You entered: " + v).set_flags (dpp::m_ephemeral);
51+ m.set_content (
52+ std::string (" You entered '" ) + message_text +
53+ " ', picked channel: <#" + channel_id + " >"
54+ )
55+ .set_flags (dpp::m_ephemeral);
5456
5557 /* Emit a reply. Form submission is still an interaction and must generate some form of reply! */
5658 event.reply (m);
0 commit comments