Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Jul 13, 2023
2 parents 981a647 + 6558527 commit afd8a8d
Show file tree
Hide file tree
Showing 13 changed files with 5,647 additions and 17 deletions.
30 changes: 29 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,35 @@
"CORO",
"cback",
"mentionables",
"awaiter",
"checkered",
"ramen",
"dango",
"tanabata",
"diya",
"nazar",
"hamsa",
"tada",
"izakaya",
"rofl",
"thumbup",
"mwgb",
"mwbb",
"wwgb",
"mwgg",
"wwbb",
"wwgg",
"mmgb",
"mmgg",
"womans",
"mans",
"mens",
"womens",
"mmbb",
"fleur",
"koko",
"moyai",
"kaaba",
"stringified"
],
"flagWords": [
Expand All @@ -104,4 +133,3 @@
"allowCompoundWords": true,
"useCompounds": true
}

18 changes: 18 additions & 0 deletions buildtools/emojis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

echo "-- Autogenrating include/dpp/unicode_emoji.h\n";

$header = "#pragma once\n\nnamespace dpp { namespace unicode_emoji {\n";

/* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
$emojis = json_decode(file_get_contents("https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json"));
if ($emojis) {
foreach ($emojis as $name=>$code) {
if (preg_match("/^\d+/", $name)) {
$name = "_" . $name;
}
$header .= " constexpr const char[] " .$name . " = \"$code\";\n";
}
$header .= "}\n};\n";
file_put_contents("include/dpp/unicode_emoji.h", $header);
}
21 changes: 21 additions & 0 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,16 @@ class DPP_EXPORT cluster {
*/
void interaction_response_edit(const std::string &token, const message &m, command_completion_event_t callback = utility::log_error());

/**
* @brief Get the original response to a slash command
*
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
* @param token Token for the interaction webhook
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::message object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
*/
void interaction_response_get_original(const std::string &token, command_completion_event_t callback = utility::log_error());

/**
* @brief Create a followup message to a slash command
*
Expand Down Expand Up @@ -1344,6 +1354,17 @@ class DPP_EXPORT cluster {
* On success the callback will contain a dpp::message object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
*/
void interaction_followup_get(const std::string &token, snowflake message_id, command_completion_event_t callback);

/**
* @brief Get the original followup message to a slash command
* This is an alias for cluster::interaction_response_get_original
* @see cluster::interaction_response_get_original
*
* @param token Token for the interaction webhook
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::message object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
*/
void interaction_followup_get_original(const std::string &token, command_completion_event_t callback = utility::log_error());

/**
* @brief Create a global slash command (a bot can have a maximum of 100 of these).
Expand Down
27 changes: 27 additions & 0 deletions include/dpp/cluster_coro_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ auto inline co_interaction_response_edit(const std::string &token, const message
return dpp::awaitable(this, [&] (auto cc) { this->interaction_response_edit(token, m, cc); });
}

/**
* @brief Get the original response to a slash command
*
* @see dpp::cluster::interaction_response_get_original
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
* @param token Token for the interaction webhook
* @return message returned object on completion
* \memberof dpp::cluster
*/
auto inline co_interaction_response_get_original(const std::string &token) {
return dpp::awaitable(this, [&] (auto cc) { this->interaction_response_get_original(token, cc); });
}

/**
* @brief Create a followup message to a slash command
*
Expand Down Expand Up @@ -354,6 +367,20 @@ auto inline co_interaction_followup_get(const std::string &token, snowflake mess
return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_get(token, message_id, cc); });
}

/**
* @brief Get the original followup message to a slash command
* This is an alias for cluster::interaction_response_get_original
* @see dpp::cluster::interaction_followup_get_original
* @see cluster::interaction_response_get_original
*
* @param token Token for the interaction webhook
* @return message returned object on completion
* \memberof dpp::cluster
*/
auto inline co_interaction_followup_get_original(const std::string &token) {
return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_get_original(token, cc); });
}

/**
* @brief Get all auto moderation rules for a guild
*
Expand Down
29 changes: 29 additions & 0 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,20 @@ confirmation interaction_response_create_sync(snowflake interaction_id, const st
*/
confirmation interaction_response_edit_sync(const std::string &token, const message &m);

/**
* @brief Get the original response to a slash command
*
* @see dpp::cluster::interaction_response_get_original
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
* @param token Token for the interaction webhook
* @return message returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
message interaction_response_get_original_sync(const std::string &token);

/**
* @brief Create a followup message to a slash command
*
Expand Down Expand Up @@ -377,6 +391,21 @@ confirmation interaction_followup_edit_sync(const std::string &token, const mess
*/
message interaction_followup_get_sync(const std::string &token, snowflake message_id);

/**
* @brief Get the original followup message to a slash command
* This is an alias for cluster::interaction_response_get_original
* @see dpp::cluster::interaction_followup_get_original
* @see cluster::interaction_response_get_original
*
* @param token Token for the interaction webhook
* @return message returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
message interaction_followup_get_original_sync(const std::string &token);

/**
* @brief Get all auto moderation rules for a guild
*
Expand Down
33 changes: 17 additions & 16 deletions include/dpp/collector.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/*
* Discord erlpack - tidied up for D++, Craig Edwards 2021.
*
* MessagePack system dependencies modified for erlpack.
*
* Copyright (C) 2008-2010 FURUHASHI Sadayuki
/************************************************************************************
*
* 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
* D++, A Lightweight C++ library for Discord
*
* http://www.apache.org/licenses/LICENSE-2.0
* Copyright 2021 Craig Edwards and D++ contributors
* (https://github.com/brainboxdotcc/DPP/graphs/contributors)
*
* 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.
*/
* 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.
*
************************************************************************************/
#pragma once

#include <dpp/export.h>
Expand Down
6 changes: 6 additions & 0 deletions include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,12 @@ struct DPP_EXPORT embed {
*/
embed& set_color(uint32_t col);

/** Set embed colour. Returns the embed itself so these method calls may be "chained"
* @param col The colour of the embed
* @return A reference to self
*/
embed& set_colour(uint32_t col);

/** Set embed timestamp. Returns the embed itself so these method calls may be "chained"
* @param tstamp The timestamp to show in the footer, should be in UTC
* @return A reference to self
Expand Down
2 changes: 2 additions & 0 deletions include/dpp/stringops.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ template <int> int from_string(const std::string &s)
template <typename T> std::string to_hex(T i)
{
std::stringstream stream;
stream.imbue(std::locale::classic());
stream << std::setfill('0') << std::setw(sizeof(T)*2) << std::hex << i;
return stream.str();
}
Expand All @@ -205,6 +206,7 @@ template <typename T> std::string to_hex(T i)
template <typename T> std::string leading_zeroes(T i, size_t width)
{
std::stringstream stream;
stream.imbue(std::locale::classic());
stream << std::setfill('0') << std::setw((int)width) << std::dec << i;
return stream.str();
}
Expand Down
Loading

0 comments on commit afd8a8d

Please sign in to comment.