-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: user app commands and test program
- Loading branch information
1 parent
7a0e5f2
commit 72ab773
Showing
6 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
Submodule doxygen-awesome-css
updated
6 files
+207 −237 | Doxyfile | |
+5 −38 | README.md | |
+1 −5 | doxygen-awesome.css | |
+1 −1 | include/MyLibrary/example.hpp | |
+14 −0 | package-lock.json | |
+1 −1 | package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/************************************************************************************ | ||
* | ||
* D++, A Lightweight C++ library for Discord | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright 2021 Craig Edwards and D++ contributors | ||
* (https://github.com/brainboxdotcc/DPP/graphs/contributors) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
************************************************************************************/ | ||
|
||
#include <dpp/dpp.h> | ||
#include <iostream> | ||
|
||
int main() { | ||
char* t = getenv("DPP_UNIT_TEST_TOKEN"); | ||
|
||
if (!t) { | ||
std::cerr << "Missing DPP_UNIT_TEST_TOKEN\n"; | ||
exit(1); | ||
} | ||
|
||
dpp::cluster bot(t, dpp::i_default_intents); | ||
bot.on_log(dpp::utility::cout_logger()); | ||
|
||
bot.on_ready([&bot](const auto& event) { | ||
if (dpp::run_once<struct boot_t>()) { | ||
/** | ||
* Create a slash command which has interaction context 'itc_private_channel'. | ||
* This is a user-app command which can be executed anywhere and is added to the user's profile. | ||
*/ | ||
bot.global_bulk_command_create({ | ||
dpp::slashcommand("userapp", "Test user app command", bot.me.id) | ||
.set_interaction_contexts({dpp::itc_guild, dpp::itc_bot_dm, dpp::itc_private_channel}) | ||
}); | ||
} | ||
}); | ||
|
||
bot.on_slashcommand([](const auto& e) { | ||
/** | ||
* Simple test output that shows the context of the command | ||
*/ | ||
if (e.command.get_command_name() != "userapp") { | ||
return; | ||
} | ||
e.reply("This is the `/userapp` command." + std::string( | ||
e.command.is_user_app_interaction() ? | ||
" Executing as a user interaction owned by user: <@" + e.command.get_authorizing_integration_owner(dpp::ait_user_install).str() + ">" : | ||
" Executing as a guild interaction on guild id " + e.command.guild_id.str() | ||
)); | ||
}); | ||
|
||
bot.start(dpp::st_wait); | ||
} |