| 1 | /************************************************************************************ |
| 2 | * |
| 3 | * D++, A Lightweight C++ library for Discord |
| 4 | * |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * Copyright 2021 Craig Edwards and D++ contributors |
| 7 | * (https://github.com/brainboxdotcc/DPP/graphs/contributors) |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | ************************************************************************************/ |
| 22 | |
| 23 | #include <dpp/dpp.h>cxx . . $ `<file>/include/dpp/dpp.h`/ |
| 24 | #include <iostream> |
| 25 | |
| 26 | int maincxx . . $ main(b126dc7c1de90089).() { |
| 27 | char* t = getenv("DPP_UNIT_TEST_TOKEN"); |
| 28 | |
| 29 | if (!t) { |
| 30 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Missing DPP_UNIT_TEST_TOKEN\n"; |
| 31 | exit(1); |
| 32 | } |
| 33 | |
| 34 | dppcxx . . $ dpp/::clustercxx . . $ dpp/cluster# botcxx . . $ dpp/cluster#cluster(13cb741d36ace229).(tcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., dppcxx . . $ dpp/::i_default_intentscxx . . $ dpp/i_default_intents.); |
| 35 | bot.on_logcxx . . $ dpp/cluster#on_log.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).dppcxx . . $ dpp/::utilitycxx . . $ dpp/utility/::cout_loggercxx . . $ dpp/utility/cout_logger(1e13570ddc4c0e10).()); |
| 36 | |
| 37 | bot.on_readycxx . . $ dpp/cluster#on_ready.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).[&bot](const auto& event) { |
| 38 | if (dppcxx . . $ dpp/::run_oncecxx . . $ dpp/run_once(a52531b27a9fa42b).<struct boot_tcxx . . $ main(b126dc7c1de90089).$anonymous_type_0#`operator()`(995e16afb875764e).boot_t#>()) { |
| 39 | /** |
| 40 | * Create a slash command which has interaction context 'itc_private_channel'. |
| 41 | * This is a user-app command which can be executed anywhere and is added to the user's profile. |
| 42 | */ |
| 43 | bot.global_bulk_command_createcxx . . $ dpp/cluster#global_bulk_command_create(aedc6ceef2a6f69a).({cxx . . $ std/vector#vector(9619226211e5a241). |
| 44 | dppcxx . . $ dpp/slashcommand#slashcommand(38368f1565ed9759).::slashcommandcxx . . $ dpp/slashcommand#("userapp"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Test command"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., botcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)..mecxx . . $ dpp/cluster#me..idcxx . . $ dpp/managed#id.) |
| 45 | .set_interaction_contextscxx . . $ dpp/slashcommand#set_interaction_contexts(f536b19597cb3576).({cxx . . $ std/vector#vector(9619226211e5a241).dppcxx . . $ dpp/::itc_guildcxx . . $ dpp/itc_guild., dppcxx . . $ dpp/::itc_bot_dmcxx . . $ dpp/itc_bot_dm., dppcxx . . $ dpp/::itc_private_channelcxx . . $ dpp/itc_private_channel.}) |
| 46 | }); |
| 47 | } |
| 48 | }); |
| 49 | |
| 50 | bot.on_button_clickcxx . . $ dpp/cluster#on_button_click.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).[](const dppcxx . . $ dpp/::button_click_tcxx . . $ dpp/button_click_t#& event) { |
| 51 | event.replycxx . . $ dpp/interaction_create_t#reply(fd6834981af6b30e).("You declared your love for cats by clicking button id: " +cxx . . $ std/operator+(42c652dfebe55ad7). event.custom_idcxx . . $ dpp/button_click_t#custom_id.); |
| 52 | }); |
| 53 | |
| 54 | bot.register_commandcxx . . $ dpp/cluster#register_command(6980d3d37aa0f21).("userapp"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., [](const dppcxx . . $ dpp/::slashcommand_tcxx . . $ dpp/slashcommand_t#& e) { |
| 55 | e.replycxx . . $ dpp/interaction_create_t#reply(9ff9f8964fde0294).(dppcxx . . $ dpp/message#message(49f6e7a06ebc5aa8).::messagecxx . . $ dpp/message#().set_flagscxx . . $ dpp/message#set_flags(8750f23ca2a85ae4).(dppcxx . . $ dpp/::m_using_components_v2cxx . . $ dpp/m_using_components_v2.).add_component_v2cxx . . $ dpp/message#add_component_v2(1b33b6728a9f1039).( |
| 56 | /* A container... */ |
| 57 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 58 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_containercxx . . $ dpp/cot_container.) |
| 59 | .set_accentcxx . . $ dpp/component#set_accent(ffafb65a60a62d9e).(dppcxx . . $ dpp/::utilitycxx . . $ dpp/utility/::rgbcxx . . $ dpp/utility/rgb(530956271a9518a5).(255, 0, 0)) |
| 60 | .set_spoilercxx . . $ dpp/component#set_spoiler(f4584d78d4366f91).(true) |
| 61 | .add_component_v2cxx . . $ dpp/component#add_component_v2(d503e336e889a058).( |
| 62 | /* ...which contains a section... */ |
| 63 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 64 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_sectioncxx . . $ dpp/cot_section.) |
| 65 | .add_component_v2cxx . . $ dpp/component#add_component_v2(d503e336e889a058).( |
| 66 | /* ...with text... */ |
| 67 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 68 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_text_displaycxx . . $ dpp/cot_text_display.) |
| 69 | .set_contentcxx . . $ dpp/component#set_content(de1ae279defae08d).("Click if you love cats"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).) |
| 70 | ) |
| 71 | .set_accessorycxx . . $ dpp/component#set_accessory(d503e336e889a058).( |
| 72 | /* ...and an accessory button to the right */ |
| 73 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 74 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_buttoncxx . . $ dpp/cot_button.) |
| 75 | .set_labelcxx . . $ dpp/component#set_label(df0e84585bba9b4f).("Click me"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 76 | .set_stylecxx . . $ dpp/component#set_style(200af93d189b695a).(dppcxx . . $ dpp/::cos_dangercxx . . $ dpp/cos_danger.) |
| 77 | .set_idcxx . . $ dpp/component#set_id(df0e84585bba9b4f).("button"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 78 | ) |
| 79 | ) |
| 80 | ).add_component_v2cxx . . $ dpp/message#add_component_v2(1b33b6728a9f1039).( |
| 81 | /* ... with a large visible divider between... */ |
| 82 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 83 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_separatorcxx . . $ dpp/cot_separator.) |
| 84 | .set_spacingcxx . . $ dpp/component#set_spacing(fecc8c2d2e27bc73).(dppcxx . . $ dpp/::sep_largecxx . . $ dpp/sep_large.) |
| 85 | .set_dividercxx . . $ dpp/component#set_divider(f4584d78d4366f91).(true) |
| 86 | ).add_component_v2cxx . . $ dpp/message#add_component_v2(1b33b6728a9f1039).( |
| 87 | /* ... followed by a media gallery... */ |
| 88 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 89 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_media_gallerycxx . . $ dpp/cot_media_gallery.) |
| 90 | .add_media_gallery_itemcxx . . $ dpp/component#add_media_gallery_item(d503e336e889a058).( |
| 91 | /* ...containing one cat pic (obviously) */ |
| 92 | dppcxx . . $ dpp/component#component(49f6e7a06ebc5aa8).::componentcxx . . $ dpp/component#() |
| 93 | .set_typecxx . . $ dpp/component#set_type(f38d65d9204892c1).(dppcxx . . $ dpp/::cot_thumbnailcxx . . $ dpp/cot_thumbnail.) |
| 94 | .set_descriptioncxx . . $ dpp/component#set_description(de1ae279defae08d).("A cat"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).) |
| 95 | .set_thumbnailcxx . . $ dpp/component#set_thumbnail(df0e84585bba9b4f).("https://www.catster.com/wp-content/uploads/2023/11/Beluga-Cat-e1714190563227.webp"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 96 | ) |
| 97 | )); |
| 98 | }); |
| 99 | |
| 100 | bot.startcxx . . $ dpp/cluster#start(fa7c3f1aeb8ff3e5).(dppcxx . . $ dpp/::st_waitcxx . . $ dpp/st_wait.); |
| 101 | } |