Vendored
+10
-10
@@ -1,16 +1,6 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Configure: Debug",
|
||||
"type": "shell",
|
||||
"command": "cd scripts; ./configure-debug.sh",
|
||||
"group": {
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"detail": "Configure Debug"
|
||||
},
|
||||
{
|
||||
"label": "Build: Debug",
|
||||
"type": "shell",
|
||||
@@ -22,6 +12,16 @@
|
||||
"problemMatcher": [],
|
||||
"detail": "Build Debug"
|
||||
},
|
||||
{
|
||||
"label": "Configure: Debug",
|
||||
"type": "shell",
|
||||
"command": "cd scripts; ./configure-debug.sh",
|
||||
"group": {
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"detail": "Configure Debug"
|
||||
},
|
||||
{
|
||||
"label": "Configure: Relwithdeb",
|
||||
"type": "shell",
|
||||
|
||||
@@ -22,3 +22,4 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/01_basics/01_first_bot")
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/01_basics/02_embeds")
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/01_basics/03_private_messages")
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/01_basics/04_adding_files")
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/01_basics/05_webhooks")
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
CPMAddPackage(
|
||||
URI "gh:brainboxdotcc/DPP@10.1.5"
|
||||
URI "gh:brainboxdotcc/DPP@10.1.6"
|
||||
OPTIONS "BUILD_VOICE_SUPPORT ON"
|
||||
OPTIONS "RUN_LDCONFIG OFF"
|
||||
OPTIONS "DPP_INSTALL OFF"
|
||||
@@ -7,5 +7,4 @@ CPMAddPackage(
|
||||
OPTIONS "DPP_NO_VCPKG ON"
|
||||
OPTIONS "DPP_NO_CONAN ON"
|
||||
OPTIONS "DPP_FORMATTERS ON"
|
||||
OPTIONS "DPP_USE_PCH ON"
|
||||
)
|
||||
OPTIONS "DPP_USE_PCH ON")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(dppbots)
|
||||
set(example_name "01_05_webhooks")
|
||||
message("Setting up ${example_name}")
|
||||
add_executable(${example_name} "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
|
||||
target_include_directories(${example_name} PUBLIC
|
||||
"${dpp_SOURCE_DIR}/include"
|
||||
"${dotenv-cpp_SOURCE_DIR}/include/laserpants"
|
||||
|
||||
)
|
||||
target_link_libraries(${example_name}
|
||||
dpp
|
||||
dotenv
|
||||
)
|
||||
SET_OUTPUT_NAMES(${example_name})
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <cluster.h>
|
||||
#include <message.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "dotenv.h"
|
||||
|
||||
int main() {
|
||||
// Load in the .env file into the environment
|
||||
dotenv::init();
|
||||
if (!std::getenv("DISCORD_WEBHOOK")) {
|
||||
std::cout << "Failed to get webhook from .env or environment"
|
||||
<< std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Get the webhook url from the environment
|
||||
std::string webhookUrl = std::getenv("DISCORD_WEBHOOK");
|
||||
|
||||
// When using webhooks, a bot token is not needed,
|
||||
// we can just create the cluster without it
|
||||
dpp::cluster bot;
|
||||
// Start the bot, returning once its initializaed
|
||||
bot.start(dpp::st_return);
|
||||
// Create a webhook object with our webhook url
|
||||
dpp::webhook wh(webhookUrl);
|
||||
|
||||
// Send a simple message over the webhook
|
||||
bot.execute_webhook(wh, dpp::message("This is a webhook message!"));
|
||||
|
||||
// Wait for all active requests to be completed
|
||||
while (bot.active_requests() > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
// Exit, the bot will automatically be cleaned up
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user