Skip to content

Commit 021f55d

Browse files
fix: fix comments
1 parent 0d6cfa7 commit 021f55d

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

include/dpp/application.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ class DPP_EXPORT application {
118118
application& fill_from_json(nlohmann::json* j);
119119
};
120120

121-
/** A group of bans
121+
/** A group of applications.
122+
* This is not currently ever sent by Discord API but the DPP standard setup for
123+
* objects that can be received by REST has the possibility for this, so this exists.
124+
* Don't ever expect to see one at present.
122125
*/
123126
typedef std::unordered_map<snowflake, application> application_map;
124127

include/dpp/discord.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,26 @@ namespace dpp {
235235
uint64_t to_msecs();
236236
};
237237

238+
/**
239+
* @brief Convert floats to RGB for sending in embeds
240+
*
241+
* @param red red value, between 0 and 1 inclusive
242+
* @param green green value, between 0 and 1 inclusive
243+
* @param blue blue value, between 0 and 1 inclusive
244+
* @return uint32_t returned integer colour value
245+
*/
246+
uint32_t rgb(float red, float green, float blue);
247+
248+
/**
249+
* @brief Convert ints to RGB for sending in embeds
250+
*
251+
* @param red red value, between 0 and 255 inclusive
252+
* @param green green value, between 0 and 255 inclusive
253+
* @param blue blue value, between 0 and 255 inclusive
254+
* @return uint32_t returned integer colour value
255+
*/
256+
uint32_t rgb(int red, int green, int blue);
257+
238258
/**
239259
* @brief Output hex values of a section of memory for debugging
240260
*

src/dpp/utility.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ namespace dpp {
188188
}
189189
}
190190

191+
uint32_t rgb(float red, float green, float blue) {
192+
return (((uint32_t)(red * 255)) << 16) | (((uint32_t)(green * 255)) << 8) | ((uint32_t)(blue * 255));
193+
}
194+
195+
/* NOTE: Parameters here are `int` instead of `uint32_t` or `uint8_t` to prevent ambiguity error with rgb(float, float, float) */
196+
uint32_t rgb(int red, int green, int blue) {
197+
return ((uint32_t)red << 16) | ((uint32_t)green << 8) | (uint32_t)blue;
198+
}
199+
191200
void exec(const std::string& cmd, std::vector<std::string> parameters, cmd_result_t callback) {
192201
auto t = std::thread([cmd, parameters, callback]() {
193202
std::array<char, 128> buffer;

0 commit comments

Comments
 (0)